Class: Spellchecker::Tokenizer::List

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/spellchecker/tokenizer/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeList

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

#lastObject (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

Parameters:

  • index (Integer)

Returns:



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]

Parameters:



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