Class: PetRescue::ListingPage

Inherits:
Object
  • Object
show all
Defined in:
lib/pet_rescue/listing_page.rb

Overview

A listing page on petrescue.com.au

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, parser) ⇒ ListingPage



12
13
14
15
16
# File 'lib/pet_rescue/listing_page.rb', line 12

def initialize(id, parser)
  @id = id
  @url = "http://www.petrescue.com.au/listings/#{@id}"
  @parser = parser
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/pet_rescue/listing_page.rb', line 6

def id
  @id
end

Class Method Details

.for_listing(id) ⇒ Object



8
9
10
# File 'lib/pet_rescue/listing_page.rb', line 8

def self.for_listing(id)
  new(id, ListingPageParser.new)
end

Instance Method Details

#petObject



18
19
20
# File 'lib/pet_rescue/listing_page.rb', line 18

def pet
  @parser.parse(open(@url))
end