Class: Lexr::Token
- Inherits:
-
Object
- Object
- Lexr::Token
- Defined in:
- lib/lexr.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(value, type = nil) ⇒ Token
constructor
A new instance of Token.
- #to_s ⇒ Object
Constructor Details
#initialize(value, type = nil) ⇒ Token
Returns a new instance of Token.
61 62 63 |
# File 'lib/lexr.rb', line 61 def initialize(value, type = nil) @value, @type = value, type end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
59 60 61 |
# File 'lib/lexr.rb', line 59 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
59 60 61 |
# File 'lib/lexr.rb', line 59 def value @value end |
Class Method Details
.method_missing(sym, *args) ⇒ Object
65 66 67 |
# File 'lib/lexr.rb', line 65 def self.method_missing(sym, *args) self.new(args.first, sym) end |
Instance Method Details
#==(other) ⇒ Object
73 74 75 |
# File 'lib/lexr.rb', line 73 def ==(other) @type == other.type && @value == other.value end |
#to_s ⇒ Object
69 70 71 |
# File 'lib/lexr.rb', line 69 def to_s "#{type}(#{value})" end |