Class: ReVIEW::ComplexInlineElementNode

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) ⇒ ComplexInlineElementNode

Returns a new instance of ComplexInlineElementNode.



943
944
945
946
947
948
# File 'lib/review/compiler.rb', line 943

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.



949
950
951
# File 'lib/review/compiler.rb', line 949

def compiler
  @compiler
end

#contentObject (readonly)

Returns the value of attribute content.



952
953
954
# File 'lib/review/compiler.rb', line 952

def content
  @content
end

#positionObject (readonly)

Returns the value of attribute position.



950
951
952
# File 'lib/review/compiler.rb', line 950

def position
  @position
end

#symbolObject (readonly)

Returns the value of attribute symbol.



951
952
953
# File 'lib/review/compiler.rb', line 951

def symbol
  @symbol
end

Instance Method Details

#to_docObject



155
156
157
158
# File 'lib/review/node.rb', line 155

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

#to_jsonObject



160
161
162
163
164
165
# File 'lib/review/node.rb', line 160

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

#to_rawObject



150
151
152
153
# File 'lib/review/node.rb', line 150

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