Class: Crags::Search::Location

Inherits:
Search
  • Object
show all
Includes:
Fetcher, ERB::Util
Defined in:
lib/crags/search/location.rb

Instance Attribute Summary collapse

Attributes inherited from Search

#category, #keyword, #opts

Instance Method Summary collapse

Methods included from Fetcher

#fetch_doc, #fetch_html, #fetch_request

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

#locationObject (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

#docObject



17
18
19
# File 'lib/crags/search/location.rb', line 17

def doc
  fetch_doc("#{url}&format=rss")
end

#itemsObject



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

#urlObject



13
14
15
# File 'lib/crags/search/location.rb', line 13

def url
  "#{location.url}/search#{category.url}?query=#{url_encode(keyword)}"
end