Class: Gonzui::SearchResult

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/gonzui/searchresult.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSearchResult

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_exceededObject

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

#clearObject



27
28
29
# File 'lib/gonzui/searchresult.rb', line 27

def clear
  @items.clear
end

#eachObject



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

Returns:

  • (Boolean)


41
42
43
# File 'lib/gonzui/searchresult.rb', line 41

def empty?
  @items.empty?
end

#firstObject



45
46
47
# File 'lib/gonzui/searchresult.rb', line 45

def first
  @items.first
end

#lastObject



49
50
51
# File 'lib/gonzui/searchresult.rb', line 49

def last
  @items.last
end

#lengthObject Also known as: nhits



53
54
55
# File 'lib/gonzui/searchresult.rb', line 53

def length
  @items.length
end

#limit_exceeded?Boolean

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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