Class: YARP::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/yarp.rb,
ext/yarp/extension.c

Overview

This represents a node in the tree.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



268
269
270
# File 'lib/yarp.rb', line 268

def location
  @location
end

Instance Method Details

#newline?Boolean

Returns:

  • (Boolean)


270
271
272
# File 'lib/yarp.rb', line 270

def newline?
  @newline ? true : false
end

#pretty_print(q) ⇒ Object



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/yarp.rb', line 282

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



274
275
276
277
278
279
280
# File 'lib/yarp.rb', line 274

def set_newline_flag(newline_marked)
  line = location.start_line
  unless newline_marked[line]
    newline_marked[line] = true
    @newline = true
  end
end