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.
51 52 53 |
# File 'lib/lexr.rb', line 51 def initialize(value, type = nil) @value, @type = value, type end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
49 50 51 |
# File 'lib/lexr.rb', line 49 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
49 50 51 |
# File 'lib/lexr.rb', line 49 def value @value end |
Class Method Details
.method_missing(sym, *args) ⇒ Object
55 56 57 |
# File 'lib/lexr.rb', line 55 def self.method_missing(sym, *args) self.new(args.first, sym) end |
Instance Method Details
#==(other) ⇒ Object
63 64 65 |
# File 'lib/lexr.rb', line 63 def ==(other) @type == other.type && @value == other.value end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/lexr.rb', line 59 def to_s "#{type}(#{value})" end |