Class: Webspinne::Index
- Inherits:
-
Object
- Object
- Webspinne::Index
- Includes:
- Enumerable
- Defined in:
- lib/webspinne/index.rb
Instance Method Summary collapse
-
#<<(link) ⇒ Object
defensive set.
- #each(&block) ⇒ Object
-
#initialize ⇒ Index
constructor
A new instance of Index.
- #next_unvisited_onsite_link ⇒ Object
- #offsite_size ⇒ Object
- #onsite_size ⇒ Object
- #size ⇒ Object
- #unvisited_size ⇒ Object
- #visited_size ⇒ Object
Constructor Details
#initialize ⇒ Index
Returns a new instance of Index.
5 6 7 |
# File 'lib/webspinne/index.rb', line 5 def initialize @list = {} end |
Instance Method Details
#<<(link) ⇒ Object
defensive set
16 17 18 |
# File 'lib/webspinne/index.rb', line 16 def << link @list[link.uri] ||= link end |
#each(&block) ⇒ Object
9 10 11 12 13 |
# File 'lib/webspinne/index.rb', line 9 def each &block @list.each do |uri, link| block.call link end end |
#next_unvisited_onsite_link ⇒ Object
24 25 26 |
# File 'lib/webspinne/index.rb', line 24 def next_unvisited_onsite_link find { |link| !link.visited? && link.onsite? } end |
#offsite_size ⇒ Object
40 41 42 |
# File 'lib/webspinne/index.rb', line 40 def offsite_size size - onsite_size end |
#onsite_size ⇒ Object
36 37 38 |
# File 'lib/webspinne/index.rb', line 36 def onsite_size find_all { |link| link.onsite? }.size end |
#size ⇒ Object
20 21 22 |
# File 'lib/webspinne/index.rb', line 20 def size @list.size end |
#unvisited_size ⇒ Object
32 33 34 |
# File 'lib/webspinne/index.rb', line 32 def unvisited_size size - visited_size end |
#visited_size ⇒ Object
28 29 30 |
# File 'lib/webspinne/index.rb', line 28 def visited_size find_all { |link| link.visited? }.size end |