Class: RBelly::Token
- Inherits:
-
Object
- Object
- RBelly::Token
- Defined in:
- lib/rbelly/token.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
Returns the value of attribute line.
-
#name ⇒ Object
Returns the value of attribute name.
-
#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.
- #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/rbelly/token.rb', line 4 def initialize(name, value, &transformer) @name = name @value = value @transformer = transformer end |
Instance Attribute Details
#line ⇒ Object
Returns the value of attribute line.
3 4 5 |
# File 'lib/rbelly/token.rb', line 3 def line @line end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/rbelly/token.rb', line 3 def name @name end |
#transformer ⇒ Object
Returns the value of attribute transformer.
3 4 5 |
# File 'lib/rbelly/token.rb', line 3 def transformer @transformer end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/rbelly/token.rb', line 3 def value @value end |
Instance Method Details
#to_racc_token ⇒ Object
10 11 12 13 |
# File 'lib/rbelly/token.rb', line 10 def to_racc_token return transformer.call(name, value) if transformer [name, value] end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/rbelly/token.rb', line 15 def to_s return "#{self.name}: #{self.value}" end |