Class: ReVIEW::InlineElementNode

Inherits:
Node show all
Defined in:
lib/review/node.rb,
lib/review/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#inspect, #to_s_by

Constructor Details

#initialize(compiler, position, symbol, content) ⇒ InlineElementNode

Returns a new instance of InlineElementNode.



1013
1014
1015
1016
1017
1018
# File 'lib/review/compiler.rb', line 1013

def initialize(compiler, position, symbol, content)
  @compiler = compiler
  @position = position
  @symbol = symbol
  @content = content
end

Instance Attribute Details

#compilerObject (readonly)

Returns the value of attribute compiler.



1019
1020
1021
# File 'lib/review/compiler.rb', line 1019

def compiler
  @compiler
end

#contentObject (readonly)

Returns the value of attribute content.



1022
1023
1024
# File 'lib/review/compiler.rb', line 1022

def content
  @content
end

#positionObject (readonly)

Returns the value of attribute position.



1020
1021
1022
# File 'lib/review/compiler.rb', line 1020

def position
  @position
end

#symbolObject (readonly)

Returns the value of attribute symbol.



1021
1022
1023
# File 'lib/review/compiler.rb', line 1021

def symbol
  @symbol
end

Instance Method Details

#to_docObject



136
137
138
139
# File 'lib/review/node.rb', line 136

def to_doc
  #content_str = super
  @compiler.compile_inline(@symbol, @content)
end

#to_jsonObject



141
142
143
144
145
146
# File 'lib/review/node.rb', line 141

def to_json
  '{"ruleName":"' + self.class.to_s.sub(/ReVIEW::/,"").sub(/Node$/,"") + '",' +
    %Q|"symbol":"#{@symbol}",| +
    "\"offset\":#{position.pos},\"line\":#{position.line},\"column\":#{position.col}," +
    (@concat ? '"childNodes":[' + @content.map(&:to_json).join(",") + ']' : '"childNodes":[]') + '}'
end

#to_rawObject



131
132
133
134
# File 'lib/review/node.rb', line 131

def to_raw
  content_str = super
  "@<#{@symbol}>{#{content_str}}"
end