Class: ToyLang::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/toy_lang/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



3
4
5
# File 'lib/toy_lang/token.rb', line 3

def content
  @content
end

#symbolObject (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

Returns:

  • (Boolean)


10
11
12
# File 'lib/toy_lang/token.rb', line 10

def is?(symbol)
  @symbol == symbol
end

#is_not?(symbol) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/toy_lang/token.rb', line 14

def is_not?(symbol)
  not is? symbol
end