Class: Gonzui::SearchResult
- Inherits:
-
Object
- Object
- Gonzui::SearchResult
- Includes:
- Enumerable
- Defined in:
- lib/gonzui/searchresult.rb
Instance Attribute Summary collapse
-
#limit_exceeded ⇒ Object
Returns the value of attribute limit_exceeded.
Instance Method Summary collapse
- #[](i) ⇒ Object
- #clear ⇒ Object
- #each ⇒ Object
- #each_from(from) ⇒ Object
- #empty? ⇒ Boolean
- #first ⇒ Object
-
#initialize ⇒ SearchResult
constructor
A new instance of SearchResult.
- #last ⇒ Object
- #length ⇒ Object (also: #nhits)
- #limit_exceeded? ⇒ Boolean
- #push(item) ⇒ Object
- #single? ⇒ Boolean
- #single_path? ⇒ Boolean
Constructor Details
#initialize ⇒ SearchResult
Returns a new instance of SearchResult.
16 17 18 19 |
# File 'lib/gonzui/searchresult.rb', line 16 def initialize @items = [] @limit_exceeded = false end |
Instance Attribute Details
#limit_exceeded ⇒ Object
Returns the value of attribute limit_exceeded.
20 21 22 |
# File 'lib/gonzui/searchresult.rb', line 20 def limit_exceeded @limit_exceeded end |
Instance Method Details
#[](i) ⇒ Object
23 24 25 |
# File 'lib/gonzui/searchresult.rb', line 23 def [] (i) @items[i] end |
#clear ⇒ Object
27 28 29 |
# File 'lib/gonzui/searchresult.rb', line 27 def clear @items.clear end |
#each ⇒ Object
31 32 33 |
# File 'lib/gonzui/searchresult.rb', line 31 def each @items.each {|item| yield(item) } end |
#each_from(from) ⇒ Object
35 36 37 38 39 |
# File 'lib/gonzui/searchresult.rb', line 35 def each_from(from) (from...@items.length).each {|i| yield(@items[i]) } end |
#empty? ⇒ Boolean
41 42 43 |
# File 'lib/gonzui/searchresult.rb', line 41 def empty? @items.empty? end |
#first ⇒ Object
45 46 47 |
# File 'lib/gonzui/searchresult.rb', line 45 def first @items.first end |
#last ⇒ Object
49 50 51 |
# File 'lib/gonzui/searchresult.rb', line 49 def last @items.last end |
#length ⇒ Object Also known as: nhits
53 54 55 |
# File 'lib/gonzui/searchresult.rb', line 53 def length @items.length end |
#limit_exceeded? ⇒ Boolean
58 59 60 |
# File 'lib/gonzui/searchresult.rb', line 58 def limit_exceeded? @limit_exceeded end |
#push(item) ⇒ Object
62 63 64 |
# File 'lib/gonzui/searchresult.rb', line 62 def push(item) @items.push(item) end |
#single? ⇒ Boolean
66 67 68 |
# File 'lib/gonzui/searchresult.rb', line 66 def single? @items.length == 1 and not @items.first.has_more? end |
#single_path? ⇒ Boolean
70 71 72 |
# File 'lib/gonzui/searchresult.rb', line 70 def single_path? @items.length == 1 and @items.first.has_more_in_path? end |