Class: RKelly::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/rkelly/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value, &transformer) ⇒ Token

Returns a new instance of Token.



4
5
6
7
8
# File 'lib/rkelly/token.rb', line 4

def initialize(name, value, &transformer)
  @name         = name
  @value        = value
  @transformer  = transformer
end

Instance Attribute Details

#lineObject

Returns the value of attribute line.



3
4
5
# File 'lib/rkelly/token.rb', line 3

def line
  @line
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/rkelly/token.rb', line 3

def name
  @name
end

#transformerObject

Returns the value of attribute transformer.



3
4
5
# File 'lib/rkelly/token.rb', line 3

def transformer
  @transformer
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/rkelly/token.rb', line 3

def value
  @value
end

Instance Method Details

#to_racc_tokenObject



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

def to_racc_token
  return transformer.call(name, value) if transformer
  [name, value]
end

#to_sObject



15
16
17
# File 'lib/rkelly/token.rb', line 15

def to_s
  return "#{self.name}: #{self.value}"
end