Class: NewEugeneListingCli::Listing
- Inherits:
-
Object
- Object
- NewEugeneListingCli::Listing
- Defined in:
- lib/new_eugene_listing_cli/listing.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#bathrooms ⇒ Object
Returns the value of attribute bathrooms.
-
#bedrooms ⇒ Object
Returns the value of attribute bedrooms.
-
#price ⇒ Object
Returns the value of attribute price.
-
#property_description ⇒ Object
Returns the value of attribute property_description.
-
#property_type ⇒ Object
Returns the value of attribute property_type.
-
#sq_feet ⇒ Object
Returns the value of attribute sq_feet.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(address = nil, price = nil, bedrooms = nil, bathrooms = nil, url = nil) ⇒ Listing
constructor
A new instance of Listing.
Constructor Details
#initialize(address = nil, price = nil, bedrooms = nil, bathrooms = nil, url = nil) ⇒ Listing
Returns a new instance of Listing.
10 11 12 13 14 15 16 17 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 10 def initialize(address = nil, price = nil, bedrooms = nil, bathrooms = nil, url = nil) @address = address @price = price @bedrooms = bedrooms @bathrooms = bathrooms @url = url @@all << self end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
2 3 4 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 2 def address @address end |
#bathrooms ⇒ Object
Returns the value of attribute bathrooms.
2 3 4 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 2 def bathrooms @bathrooms end |
#bedrooms ⇒ Object
Returns the value of attribute bedrooms.
2 3 4 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 2 def bedrooms @bedrooms end |
#price ⇒ Object
Returns the value of attribute price.
2 3 4 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 2 def price @price end |
#property_description ⇒ Object
Returns the value of attribute property_description.
2 3 4 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 2 def property_description @property_description end |
#property_type ⇒ Object
Returns the value of attribute property_type.
2 3 4 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 2 def property_type @property_type end |
#sq_feet ⇒ Object
Returns the value of attribute sq_feet.
2 3 4 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 2 def sq_feet @sq_feet end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
6 7 8 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 6 def self.all @@all end |
.new_from_index_page(p) ⇒ Object
19 20 21 22 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 19 def self.new_from_index_page(p) self.new(p.css(".addressDetail .h6").text.strip, p.css(".cardPrice").text.strip, p.css("[data-auto-test='beds']").text.gsub("bd", "").strip, p.css("[data-auto-test='baths']").text.gsub("ba", "").strip, "https://www.trulia.com" + p.css("a")[0]["href"].strip) end |
Instance Method Details
#doc ⇒ Object
36 37 38 |
# File 'lib/new_eugene_listing_cli/listing.rb', line 36 def doc @doc = Nokogiri::HTML(rpage = open(self.url, "User-Agent" => "User").read) end |