Class: YARP::Node
- Inherits:
-
Object
- Object
- YARP::Node
- Defined in:
- lib/yarp.rb,
ext/yarp/extension.c
Overview
This represents a node in the tree.
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
- #newline? ⇒ Boolean
- #pretty_print(q) ⇒ Object
- #set_newline_flag(newline_marked) ⇒ Object
-
#slice ⇒ Object
Slice the location of the node from the source.
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
290 291 292 |
# File 'lib/yarp.rb', line 290 def location @location end |
Instance Method Details
#newline? ⇒ Boolean
292 293 294 |
# File 'lib/yarp.rb', line 292 def newline? @newline ? true : false end |
#pretty_print(q) ⇒ Object
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/yarp.rb', line 309 def pretty_print(q) q.group do q.text(self.class.name.split("::").last) location.pretty_print(q) q.text("[Li:#{location.start_line}]") if newline? q.text("(") q.nest(2) do deconstructed = deconstruct_keys([]) deconstructed.delete(:location) q.breakable("") q.seplist(deconstructed, lambda { q.comma_breakable }, :each_value) { |value| q.pp(value) } end q.breakable("") q.text(")") end end |
#set_newline_flag(newline_marked) ⇒ Object
296 297 298 299 300 301 302 |
# File 'lib/yarp.rb', line 296 def set_newline_flag(newline_marked) line = location.start_line unless newline_marked[line] newline_marked[line] = true @newline = true end end |
#slice ⇒ Object
Slice the location of the node from the source.
305 306 307 |
# File 'lib/yarp.rb', line 305 def slice location.slice end |