Class: RKelly::Token
- Inherits:
-
Object
- Object
- RKelly::Token
- Defined in:
- lib/rkelly/token.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#range ⇒ Object
Returns the value of attribute range.
-
#transformer ⇒ Object
Returns the value of attribute transformer.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, value, &transformer) ⇒ Token
constructor
A new instance of Token.
-
#line ⇒ Object
For backwards compatibility.
- #to_racc_token ⇒ Object
- #to_s ⇒ Object
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 if transformer end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/rkelly/token.rb', line 3 def name @name end |
#range ⇒ Object
Returns the value of attribute range.
3 4 5 |
# File 'lib/rkelly/token.rb', line 3 def range @range end |
#transformer ⇒ Object
Returns the value of attribute transformer.
3 4 5 |
# File 'lib/rkelly/token.rb', line 3 def transformer @transformer end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/rkelly/token.rb', line 3 def value @value end |
Instance Method Details
#line ⇒ Object
For backwards compatibility
11 12 13 |
# File 'lib/rkelly/token.rb', line 11 def line @range.from.line end |
#to_racc_token ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rkelly/token.rb', line 15 def to_racc_token if @transformer @name, @value = @transformer.call(@name, @value) @transformer = nil end [@name, @value] end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/rkelly/token.rb', line 23 def to_s return "#{self.name}: #{self.value}" end |