Class: Bigdeal
Instance Method Summary
collapse
#connect_to_auction, #start_monitoring
Constructor Details
#initialize(url, options) ⇒ Bigdeal
Returns a new instance of Bigdeal.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/auto_bidder/bigdeal.rb', line 4
def initialize(url, options)
@auction_url = url
@auction_id = @auction_url.match(/([\d]+\Z)/)[0]
@browser = BrowserInterface.new @auction_url
@max_price = options[:max_price]
@min_price = options[:min_price]
@bid_cost = options[:bid_cost]
@bid_secs = options[:bid_secs]
@username = options[:username]
@password = options[:password]
@num_bids = 0
end
|
Instance Method Details
#execute_bid ⇒ Object
46
47
48
|
# File 'lib/auto_bidder/bigdeal.rb', line 46
def execute_bid
@browser.div(:id, "#{@auction_id}-bid_button").click
end
|
#get_current_price ⇒ Object
19
20
21
|
# File 'lib/auto_bidder/bigdeal.rb', line 19
def get_current_price
@browser.span(:id, "#{@auction_id}-price").text.delete('$').to_f
end
|
50
51
52
|
# File 'lib/auto_bidder/bigdeal.rb', line 50
def get_formatted_price
@browser.span(:id, @auction_id + "-price").text
end
|
#get_hours ⇒ Object
34
35
36
|
# File 'lib/auto_bidder/bigdeal.rb', line 34
def get_hours
@browser.span(:id, "#{@auction_id}-hours_remaining").text.to_i
end
|
#get_mins ⇒ Object
38
39
40
|
# File 'lib/auto_bidder/bigdeal.rb', line 38
def get_mins
@browser.span(:id, "#{@auction_id}-minutes_remaining").text.to_i
end
|
#get_secs ⇒ Object
42
43
44
|
# File 'lib/auto_bidder/bigdeal.rb', line 42
def get_secs
@browser.span(:id, "#{@auction_id}-seconds_remaining").text.to_i
end
|
#sign_in ⇒ Object
27
28
29
30
31
32
|
# File 'lib/auto_bidder/bigdeal.rb', line 27
def sign_in
@browser.link(:text, /Login/).click
@browser.text_field(:id, "userNameOrEmail").set(@username)
@browser.text_field(:id, "password").set(@password)
@browser.form(:action, /login/).submit
end
|
#signed_in? ⇒ Boolean
23
24
25
|
# File 'lib/auto_bidder/bigdeal.rb', line 23
def signed_in?
@browser.link(:text, /Logout/).exists?
end
|