Class: Craig::Craigslist

Inherits:
Object
  • Object
show all
Defined in:
lib/craig/craigslist.rb

Overview

Translates our gem’s inputs into the request to fetch Craigslist listings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(city, categories) ⇒ Craigslist

Returns a new instance of Craigslist.



7
8
9
10
# File 'lib/craig/craigslist.rb', line 7

def initialize(city, categories)
  @city = city
  @category, @subcategory = *Array(categories).flatten
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



5
6
7
# File 'lib/craig/craigslist.rb', line 5

def category
  @category
end

#cityObject (readonly)

Returns the value of attribute city.



5
6
7
# File 'lib/craig/craigslist.rb', line 5

def city
  @city
end

#subcategoryObject (readonly)

Returns the value of attribute subcategory.



5
6
7
# File 'lib/craig/craigslist.rb', line 5

def subcategory
  @subcategory
end

Instance Method Details

#listingsObject



12
13
14
# File 'lib/craig/craigslist.rb', line 12

def listings
  Page.new(category, subcategory, dom).listings
end