Class: Crags::Search::Country

Inherits:
Search
  • Object
show all
Defined in:
lib/crags/search/country.rb

Instance Attribute Summary collapse

Attributes inherited from Search

#category, #keyword, #opts

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Country

Returns a new instance of Country.



6
7
8
9
10
# File 'lib/crags/search/country.rb', line 6

def initialize(opts = {})
  super
  @country = @opts[:country]
  @interval = @opts[:interval]
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



4
5
6
# File 'lib/crags/search/country.rb', line 4

def country
  @country
end

#intervalObject (readonly)

Returns the value of attribute interval.



4
5
6
# File 'lib/crags/search/country.rb', line 4

def interval
  @interval
end

Instance Method Details

#itemsObject



16
17
18
19
20
21
22
23
# File 'lib/crags/search/country.rb', line 16

def items
  combined_items = locations.collect do |loc|
    sleep(interval)
    search = Location.new(opts.merge(:location => loc))
    search.items
  end
  combined_items.flatten
end

#locationsObject



12
13
14
# File 'lib/crags/search/country.rb', line 12

def locations
  country.locations
end