Class: Spellchecker::Tokenizer::List
- Inherits:
-
Object
- Object
- Spellchecker::Tokenizer::List
- Includes:
- Enumerable
- Defined in:
- lib/spellchecker/tokenizer/list.rb
Instance Attribute Summary collapse
-
#last ⇒ Object
readonly
Returns the value of attribute last.
Instance Method Summary collapse
- #[](index) ⇒ Spellchecker::Tokenizer::Token
-
#add(token) ⇒ Object
(also: #<<)
return [Spellchecker::Tokenizer::Token].
- #each(&block) ⇒ Object
-
#initialize ⇒ List
constructor
A new instance of List.
Constructor Details
#initialize ⇒ List
Returns a new instance of List.
10 11 12 13 |
# File 'lib/spellchecker/tokenizer/list.rb', line 10 def initialize @list = [] @last = Tokenizer::NULL_TOKEN end |
Instance Attribute Details
#last ⇒ Object (readonly)
Returns the value of attribute last.
8 9 10 |
# File 'lib/spellchecker/tokenizer/list.rb', line 8 def last @last end |
Instance Method Details
#[](index) ⇒ Spellchecker::Tokenizer::Token
34 35 36 |
# File 'lib/spellchecker/tokenizer/list.rb', line 34 def [](index) @list[index] end |
#add(token) ⇒ Object Also known as: <<
return [Spellchecker::Tokenizer::Token]
17 18 19 20 21 22 23 24 25 |
# File 'lib/spellchecker/tokenizer/list.rb', line 17 def add(token) @last.next = token token.prev = @last @list << token @last = token token end |
#each(&block) ⇒ Object
28 29 30 |
# File 'lib/spellchecker/tokenizer/list.rb', line 28 def each(&block) @list.each(&block) end |