Class: Craigslister
- Inherits:
-
Object
- Object
- Craigslister
- Defined in:
- lib/craigslister/craigslister.rb
Overview
Creates url from arguments and scrapes
Instance Attribute Summary collapse
-
#area ⇒ Object
readonly
Returns the value of attribute area.
-
#high ⇒ Object
readonly
Returns the value of attribute high.
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#low ⇒ Object
readonly
Returns the value of attribute low.
Instance Method Summary collapse
-
#initialize(args) ⇒ Craigslister
constructor
A new instance of Craigslister.
- #posts ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(args) ⇒ Craigslister
Returns a new instance of Craigslister.
9 10 11 12 13 14 15 |
# File 'lib/craigslister/craigslister.rb', line 9 def initialize(args) @area = args.fetch(:area, 'sfbay') @item = args[:item] @high = args.fetch(:high, nil) @low = args.fetch(:low, nil) validate_price_range end |
Instance Attribute Details
#area ⇒ Object (readonly)
Returns the value of attribute area.
7 8 9 |
# File 'lib/craigslister/craigslister.rb', line 7 def area @area end |
#high ⇒ Object (readonly)
Returns the value of attribute high.
7 8 9 |
# File 'lib/craigslister/craigslister.rb', line 7 def high @high end |
#item ⇒ Object (readonly)
Returns the value of attribute item.
7 8 9 |
# File 'lib/craigslister/craigslister.rb', line 7 def item @item end |
#low ⇒ Object (readonly)
Returns the value of attribute low.
7 8 9 |
# File 'lib/craigslister/craigslister.rb', line 7 def low @low end |
Instance Method Details
#posts ⇒ Object
17 18 19 |
# File 'lib/craigslister/craigslister.rb', line 17 def posts LinkScraper.new(url, base_url).posts end |
#url ⇒ Object
21 22 23 24 25 |
# File 'lib/craigslister/craigslister.rb', line 21 def url "#{base_url}/search/sss?sort=rel&"\ "#{price_query}query="\ "#{item.downcase.split(' ') * '+'}" end |