Sha256: 949c749d57c83643c150ed23dbc36dd32098d39142b45921056adebfe596c336

Contents?: true

Size: 903 Bytes

Versions: 4

Compression:

Stored size: 903 Bytes

Contents

require 'mechanize'

require 'goodwill/csspaths'
require 'goodwill/urlpaths'
require 'goodwill/mechanize'

module Goodwill
  class Auction
    include Goodwill::Mechanize
    include CSSPaths
    include URLPaths

    attr_reader :bids
    attr_reader :current
    attr_reader :end
    attr_reader :href
    attr_reader :item
    attr_reader :itemid
    attr_reader :seller

    def initialize(itemid = nil)
      @href = ITEM_SEARCH_URL + itemid.to_s
      @itemid = itemid
      item_page = mechanize.get(@href)
      @bids = item_page.search(BIDS_PATH).text[/\d+/]
      @current = item_page.search(CURRENT_PRICE_PATH).text
      @end = item_page.search(END_TIME_PATH).text
      @item = item_page.search(ITEM_TITLE_PATH).text
      @seller = item_page.search(SELLER_PATH).text
      @bidding = false
    end

    def ==(another_auction)
      self.itemid == another_auction.itemid
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
goodwill-0.1.4 lib/goodwill/auction.rb
goodwill-0.1.3 lib/goodwill/auction.rb
goodwill-0.1.2 lib/goodwill/auction.rb
goodwill-0.1.0 lib/goodwill/auction.rb