Class | CodeRay::Encoders::JSON |
In: |
lib/coderay/encoders/json.rb
|
Parent: | Encoder |
Example:
CodeRay.scan('puts "Hello world!"', :ruby).json
yields
[ {"type"=>"text", "text"=>"puts", "kind"=>"ident"}, {"type"=>"text", "text"=>" ", "kind"=>"space"}, {"type"=>"block", "action"=>"open", "kind"=>"string"}, {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"}, {"type"=>"text", "text"=>"Hello world!", "kind"=>"content"}, {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"}, {"type"=>"block", "action"=>"close", "kind"=>"string"}, ]
FILE_EXTENSION | = | 'json' |
# File lib/coderay/encoders/json.rb, line 64 64: def begin_group kind 65: append :type => 'block', :action => 'open', :kind => kind 66: end
# File lib/coderay/encoders/json.rb, line 72 72: def begin_line kind 73: append :type => 'block', :action => 'begin_line', :kind => kind 74: end
# File lib/coderay/encoders/json.rb, line 68 68: def end_group kind 69: append :type => 'block', :action => 'close', :kind => kind 70: end
# File lib/coderay/encoders/json.rb, line 76 76: def end_line kind 77: append :type => 'block', :action => 'end_line', :kind => kind 78: end
# File lib/coderay/encoders/json.rb, line 60 60: def text_token text, kind 61: append :type => 'text', :text => text, :kind => kind 62: end
# File lib/coderay/encoders/json.rb, line 49 49: def append data 50: if @first 51: @first = false 52: else 53: @out << ',' 54: end 55: 56: @out << data.to_json 57: end