Class: Raingrams::Tokens::Token
Direct Known Subclasses
Instance Attribute Summary collapse
-
#gram ⇒ Object
readonly
Gram form of the token.
Instance Method Summary collapse
-
#*(length) ⇒ Object
Creates an Array of the specified length containing the token.
-
#eql?(other) ⇒ Boolean
(also: #==)
Returns
true
if the token has the same gram as the other token, returnsfalse
otherwise. -
#initialize(gram) ⇒ Token
constructor
Creates a new Token object with the specified gram.
-
#inspect ⇒ Object
Returns the String form of the token.
- #to_gram ⇒ Object
-
#to_s ⇒ Object
Returns the String form of the token.
-
#to_sym ⇒ Object
Returns the Symbol form of the token.
Constructor Details
#initialize(gram) ⇒ Token
Creates a new Token object with the specified gram.
11 12 13 |
# File 'lib/raingrams/tokens/token.rb', line 11 def initialize(gram) @gram = gram end |
Instance Attribute Details
#gram ⇒ Object (readonly)
Gram form of the token
6 7 8 |
# File 'lib/raingrams/tokens/token.rb', line 6 def gram @gram end |
Instance Method Details
#*(length) ⇒ Object
Creates an Array of the specified length containing the token.
22 23 24 |
# File 'lib/raingrams/tokens/token.rb', line 22 def *(length) [self] * length end |
#eql?(other) ⇒ Boolean Also known as: ==
Returns true
if the token has the same gram as the other token, returns false
otherwise.
30 31 32 33 34 35 36 |
# File 'lib/raingrams/tokens/token.rb', line 30 def eql?(other) if other.kind_of?(Token) return (@gram == other.gram) end return false end |
#inspect ⇒ Object
Returns the String form of the token.
57 58 59 |
# File 'lib/raingrams/tokens/token.rb', line 57 def inspect @gram.to_s end |
#to_gram ⇒ Object
15 16 17 |
# File 'lib/raingrams/tokens/token.rb', line 15 def to_gram self end |
#to_s ⇒ Object
Returns the String form of the token.
43 44 45 |
# File 'lib/raingrams/tokens/token.rb', line 43 def to_s @gram.to_s end |
#to_sym ⇒ Object
Returns the Symbol form of the token.
50 51 52 |
# File 'lib/raingrams/tokens/token.rb', line 50 def to_sym @gram.to_sym end |