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.
284 285 286 |
# File 'lib/yarp.rb', line 284 def location @location end |
Instance Method Details
#newline? ⇒ Boolean
286 287 288 |
# File 'lib/yarp.rb', line 286 def newline? @newline ? true : false end |
#pretty_print(q) ⇒ Object
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/yarp.rb', line 303 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
290 291 292 293 294 295 296 |
# File 'lib/yarp.rb', line 290 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.
299 300 301 |
# File 'lib/yarp.rb', line 299 def slice location.slice end |