Class: ReVIEW::TextNode
- Defined in:
- lib/review/node.rb,
lib/review/compiler.rb
Instance Attribute Summary collapse
-
#compiler ⇒ Object
readonly
Returns the value of attribute compiler.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
-
#initialize(compiler, position, content) ⇒ TextNode
constructor
A new instance of TextNode.
- #to_doc ⇒ Object
- #to_json(*args) ⇒ Object
- #to_raw ⇒ Object
Methods inherited from Node
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
#compiler ⇒ Object (readonly)
Returns the value of attribute compiler.
1114 1115 1116 |
# File 'lib/review/compiler.rb', line 1114 def compiler @compiler end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
1116 1117 1118 |
# File 'lib/review/compiler.rb', line 1116 def content @content end |
#position ⇒ Object (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_doc ⇒ Object
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_raw ⇒ Object
176 177 178 179 |
# File 'lib/review/node.rb', line 176 def to_raw content_str = super content_str.to_s end |