Class: Ruby::Node

Inherits:
Object show all
Includes:
Comparable, Conversions, Composite, Source, Traversal
Defined in:
lib/ruby/node.rb,
lib/ruby/node/text.rb,
lib/ruby/node/source.rb,
lib/ruby/node/position.rb,
lib/ruby/node/composite.rb,
lib/ruby/node/traversal.rb

Direct Known Subclasses

Aggregate, Token

Defined Under Namespace

Modules: Composite, Source, Traversal Classes: Position, Text

Instance Attribute Summary

Attributes included from Composite

#parent

Instance Method Summary collapse

Methods included from Conversions

included, #to_node

Methods included from Traversal

#has_token?, #has_type?, #has_value?, #is_instance_of?, #left_of?, #matches?, #position?, #right_of?, #select

Methods included from Source

#context, #filename, #line, #lines, #src

Methods included from Composite

included, #root, #root?

Instance Method Details

#<=>(other) ⇒ Object



36
37
38
# File 'lib/ruby/node.rb', line 36

def <=>(other)
  position <=> (other.respond_to?(:position) ? other.position : other)
end

#all_nodesObject



32
33
34
# File 'lib/ruby/node.rb', line 32

def all_nodes
  nodes + nodes.map { |node| node.all_nodes }.flatten
end

#columnObject



20
21
22
# File 'lib/ruby/node.rb', line 20

def column
  position[1]
end

#length(prolog = false) ⇒ Object



24
25
26
# File 'lib/ruby/node.rb', line 24

def length(prolog = false)
  to_ruby(prolog).length
end

#nodesObject



28
29
30
# File 'lib/ruby/node.rb', line 28

def nodes
  []
end

#rowObject



16
17
18
# File 'lib/ruby/node.rb', line 16

def row
  position[0]
end