Class: Logicality::Lexer::Token
- Inherits:
-
Object
- Object
- Logicality::Lexer::Token
- Defined in:
- lib/logicality/lexer/token.rb
Defined Under Namespace
Modules: Type
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(type, value) ⇒ Token
constructor
A new instance of Token.
- #to_s ⇒ Object
Constructor Details
#initialize(type, value) ⇒ Token
Returns a new instance of Token.
23 24 25 26 27 28 29 |
# File 'lib/logicality/lexer/token.rb', line 23 def initialize(type, value) raise ArgumentError, 'type is required' unless type && type.to_s.length > 0 raise ArgumentError, 'value is required' unless value && value.to_s.length > 0 @type = Type.const_get(type.to_s.upcase.to_sym) @value = value.to_s end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
21 22 23 |
# File 'lib/logicality/lexer/token.rb', line 21 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
21 22 23 |
# File 'lib/logicality/lexer/token.rb', line 21 def value @value end |
Instance Method Details
#to_s ⇒ Object
31 32 33 |
# File 'lib/logicality/lexer/token.rb', line 31 def to_s "#{type}::#{value}" end |