Class: Crags::Search::Location
- Includes:
- Fetcher, ERB::Util
- Defined in:
- lib/crags/search/location.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Attributes inherited from Search
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(opts = {}) ⇒ Location
constructor
A new instance of Location.
- #items ⇒ Object
- #url ⇒ Object
Methods included from Fetcher
#fetch_doc, #fetch_request, #fetch_xml
Constructor Details
#initialize(opts = {}) ⇒ Location
Returns a new instance of Location.
8 9 10 11 |
# File 'lib/crags/search/location.rb', line 8 def initialize(opts = {}) super(opts) @location = @opts[:location] end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
6 7 8 |
# File 'lib/crags/search/location.rb', line 6 def location @location end |
Instance Method Details
#doc ⇒ Object
17 18 19 |
# File 'lib/crags/search/location.rb', line 17 def doc fetch_doc("#{url}&format=rss") end |
#items ⇒ Object
21 22 23 24 25 |
# File 'lib/crags/search/location.rb', line 21 def items doc.search("item").collect do |elem| Item.new(elem) end end |
#url ⇒ Object
13 14 15 |
# File 'lib/crags/search/location.rb', line 13 def url "#{location.url}/search#{category.url}?query=#{url_encode(keyword)}" end |