Class: ToyLang::Token
- Inherits:
-
Object
- Object
- ToyLang::Token
- Defined in:
- lib/toy_lang/token.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
-
#initialize(symbol, content = nil) ⇒ Token
constructor
A new instance of Token.
- #is?(symbol) ⇒ Boolean
- #is_not?(symbol) ⇒ Boolean
Constructor Details
#initialize(symbol, content = nil) ⇒ Token
Returns a new instance of Token.
5 6 7 8 |
# File 'lib/toy_lang/token.rb', line 5 def initialize(symbol, content = nil) @symbol = symbol @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
3 4 5 |
# File 'lib/toy_lang/token.rb', line 3 def content @content end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
3 4 5 |
# File 'lib/toy_lang/token.rb', line 3 def symbol @symbol end |
Instance Method Details
#is?(symbol) ⇒ Boolean
10 11 12 |
# File 'lib/toy_lang/token.rb', line 10 def is?(symbol) @symbol == symbol end |
#is_not?(symbol) ⇒ Boolean
14 15 16 |
# File 'lib/toy_lang/token.rb', line 14 def is_not?(symbol) not is? symbol end |