Class: Keisan::Token
- Inherits:
-
Object
show all
- Defined in:
- lib/keisan/token.rb
Direct Known Subclasses
Keisan::Tokens::Boolean, Keisan::Tokens::Colon, Keisan::Tokens::Comma, Keisan::Tokens::Dot, Keisan::Tokens::Group, Keisan::Tokens::LineSeparator, Keisan::Tokens::Null, Keisan::Tokens::Number, Keisan::Tokens::Operator, Keisan::Tokens::String, Keisan::Tokens::Unknown, Keisan::Tokens::Word
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(string) ⇒ Token
Returns a new instance of Token.
5
6
7
8
|
# File 'lib/keisan/token.rb', line 5
def initialize(string)
raise Exceptions::InvalidToken.new(string) unless string.match(regex)
@string = string
end
|
Instance Attribute Details
#string ⇒ Object
Returns the value of attribute string.
3
4
5
|
# File 'lib/keisan/token.rb', line 3
def string
@string
end
|
Class Method Details
.type ⇒ Object
14
15
16
|
# File 'lib/keisan/token.rb', line 14
def self.type
@type ||= Util.underscore(self.to_s.split("::").last).to_sym
end
|
Instance Method Details
#regex ⇒ Object
18
19
20
|
# File 'lib/keisan/token.rb', line 18
def regex
self.class.regex
end
|
#type ⇒ Object
10
11
12
|
# File 'lib/keisan/token.rb', line 10
def type
self.class.type
end
|