Class: Ruby::Token

Inherits:
Node show all
Includes:
Conversions::Token
Defined in:
lib/ruby/token.rb

Instance Attribute Summary collapse

Attributes included from Node::Composite

#parent

Instance Method Summary collapse

Methods included from Conversions::Token

#to_identifier, #to_string_content

Methods inherited from Node

#<=>, #all_nodes, #column, #length, #nodes, #row

Methods included from Conversions

included, #to_node

Methods included from Node::Traversal

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

Methods included from Node::Source

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

Methods included from Node::Composite

included, #root, #root?

Constructor Details

#initialize(token = '', position = nil, prolog = nil) ⇒ Token

Returns a new instance of Token.



9
10
11
12
13
# File 'lib/ruby/token.rb', line 9

def initialize(token = '', position = nil, prolog = nil)
  self.token = token
  self.position = position if position
  self.prolog = prolog || Prolog.new
end

Instance Attribute Details

#position(prolog = false) ⇒ Object

Returns the value of attribute position.



7
8
9
# File 'lib/ruby/token.rb', line 7

def position
  @position
end

#prologObject

Returns the value of attribute prolog.



7
8
9
# File 'lib/ruby/token.rb', line 7

def prolog
  @prolog
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/ruby/token.rb', line 7

def token
  @token
end

Instance Method Details

#to_ruby(prolog = false) ⇒ Object



27
28
29
# File 'lib/ruby/token.rb', line 27

def to_ruby(prolog = false)
  (prolog && self.prolog.try(:to_ruby, prolog) || '') + token.to_s
end

#to_sObject



23
24
25
# File 'lib/ruby/token.rb', line 23

def to_s
  token.to_s
end