Class: Dhaka::TokenizerState
- Inherits:
-
Object
- Object
- Dhaka::TokenizerState
- Defined in:
- lib/tokenizer/tokenizer.rb
Overview
A tokenizer state encapsulates actions that should be performed upon encountering each permissible character for that state.
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
Instance Method Summary collapse
-
#for_characters(characters, &blk) ⇒ Object
(also: #for_character)
Define the action (
blk
) to be performed when encountering any ofcharacters
in the token stream. -
#initialize ⇒ TokenizerState
constructor
A new instance of TokenizerState.
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ TokenizerState
Returns a new instance of TokenizerState.
42 43 44 |
# File 'lib/tokenizer/tokenizer.rb', line 42 def initialize @actions = {} end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
40 41 42 |
# File 'lib/tokenizer/tokenizer.rb', line 40 def actions @actions end |
Instance Method Details
#for_characters(characters, &blk) ⇒ Object Also known as: for_character
Define the action (blk
) to be performed when encountering any of characters
in the token stream.
47 48 49 50 51 |
# File 'lib/tokenizer/tokenizer.rb', line 47 def for_characters(characters, &blk) characters.each do |character| actions[character] = blk end end |
#to_s ⇒ Object
:nodoc:
55 56 57 |
# File 'lib/tokenizer/tokenizer.rb', line 55 def to_s #:nodoc: actions.inspect end |