Class: Goodwill::Auction

Inherits:
Object
  • Object
show all
Includes:
CSSPaths, Mechanize, URLPaths
Defined in:
lib/goodwill/auction.rb

Direct Known Subclasses

BiddingAuction

Constant Summary

Constants included from URLPaths

URLPaths::ITEM_SEARCH_URL, URLPaths::LOGIN_URL, URLPaths::OPEN_ORDERS_URL, URLPaths::SEARCH_URL

Constants included from CSSPaths

CSSPaths::BIDS_PATH, CSSPaths::CURRENT_PRICE_PATH, CSSPaths::END_TIME_PATH, CSSPaths::ITEMID_PATH, CSSPaths::ITEM_TITLE_PATH, CSSPaths::SELLER_PATH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mechanize

logged_in?, login, #mechanize, mechanize

Constructor Details

#initialize(itemid = nil) ⇒ Auction

Returns a new instance of Auction.

[View source]

21
22
23
24
25
26
27
28
29
30
31
# File 'lib/goodwill/auction.rb', line 21

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

Instance Attribute Details

#bidsObject (readonly)

Returns the value of attribute bids.


13
14
15
# File 'lib/goodwill/auction.rb', line 13

def bids
  @bids
end

#currentObject (readonly)

Returns the value of attribute current.


14
15
16
# File 'lib/goodwill/auction.rb', line 14

def current
  @current
end

#endObject (readonly)

Returns the value of attribute end.


15
16
17
# File 'lib/goodwill/auction.rb', line 15

def end
  @end
end

#hrefObject (readonly)

Returns the value of attribute href.


16
17
18
# File 'lib/goodwill/auction.rb', line 16

def href
  @href
end

#itemObject (readonly)

Returns the value of attribute item.


17
18
19
# File 'lib/goodwill/auction.rb', line 17

def item
  @item
end

#itemidObject (readonly)

Returns the value of attribute itemid.


18
19
20
# File 'lib/goodwill/auction.rb', line 18

def itemid
  @itemid
end

#sellerObject (readonly)

Returns the value of attribute seller.


19
20
21
# File 'lib/goodwill/auction.rb', line 19

def seller
  @seller
end

Instance Method Details

#==(another_auction) ⇒ Object

[View source]

33
34
35
# File 'lib/goodwill/auction.rb', line 33

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