Class: Keisan::Token
- Inherits:
-
Object
show all
- Defined in:
- lib/keisan/token.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(string) ⇒ Token
Returns a new instance of Token.
4
5
6
7
|
# File 'lib/keisan/token.rb', line 4
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
13
14
15
|
# File 'lib/keisan/token.rb', line 13
def self.type
@type ||= self.to_s.split("::").last.underscore.to_sym
end
|
Instance Method Details
#regex ⇒ Object
17
18
19
|
# File 'lib/keisan/token.rb', line 17
def regex
self.class.regex
end
|
#type ⇒ Object
9
10
11
|
# File 'lib/keisan/token.rb', line 9
def type
self.class.type
end
|