Class: ReVIEW::TextNode

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, content) ⇒ TextNode

Returns a new instance of TextNode.



1109
1110
1111
1112
1113
# File 'lib/review/compiler.rb', line 1109

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

Instance Attribute Details

#compilerObject (readonly)

Returns the value of attribute compiler.



1114
1115
1116
# File 'lib/review/compiler.rb', line 1114

def compiler
  @compiler
end

#contentObject (readonly)

Returns the value of attribute content.



1116
1117
1118
# File 'lib/review/compiler.rb', line 1116

def content
  @content
end

#positionObject (readonly)

Returns the value of attribute position.



1115
1116
1117
# File 'lib/review/compiler.rb', line 1115

def position
  @position
end

Instance Method Details

#to_docObject



181
182
183
184
# File 'lib/review/node.rb', line 181

def to_doc
  content_str = super
  @compiler.compile_text(content_str)
end

#to_json(*args) ⇒ Object



186
187
188
189
190
191
# File 'lib/review/node.rb', line 186

def to_json(*args)
  val = '"'+@content.gsub(/\"/,'\\"').gsub(/\n/,'\\n')+'"'
  '{"ruleName":"' + self.class.to_s.sub(/ReVIEW::/,"").sub(/Node$/,"") + '",' +
    "\"offset\":#{position.pos},\"line\":#{position.line},\"column\":#{position.col}," +
    '"text":' + val + '}'
end

#to_rawObject



176
177
178
179
# File 'lib/review/node.rb', line 176

def to_raw
  content_str = super
  content_str.to_s
end