Class: Dentaku::Token
- Inherits:
-
Object
- Object
- Dentaku::Token
- Defined in:
- lib/dentaku/token.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#raw_value ⇒ Object
readonly
Returns the value of attribute raw_value.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(category, value, raw_value = nil) ⇒ Token
constructor
A new instance of Token.
- #is?(c) ⇒ Boolean
- #length ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(category, value, raw_value = nil) ⇒ Token
Returns a new instance of Token.
5 6 7 8 9 |
# File 'lib/dentaku/token.rb', line 5 def initialize(category, value, raw_value=nil) @category = category @value = value @raw_value = raw_value end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
3 4 5 |
# File 'lib/dentaku/token.rb', line 3 def category @category end |
#raw_value ⇒ Object (readonly)
Returns the value of attribute raw_value.
3 4 5 |
# File 'lib/dentaku/token.rb', line 3 def raw_value @raw_value end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/dentaku/token.rb', line 3 def value @value end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 26 |
# File 'lib/dentaku/token.rb', line 23 def ==(other) (category.nil? || other.category.nil? || category == other.category) && (value.nil? || other.value.nil? || value == other.value) end |
#is?(c) ⇒ Boolean
19 20 21 |
# File 'lib/dentaku/token.rb', line 19 def is?(c) category == c end |
#length ⇒ Object
15 16 17 |
# File 'lib/dentaku/token.rb', line 15 def length raw_value.to_s.length end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/dentaku/token.rb', line 11 def to_s raw_value || value end |