beway 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +7 -0
- data/Gemfile.lock +34 -0
- data/README +43 -0
- data/README.rdoc +43 -0
- data/Rakefile +19 -0
- data/bin/beway +5 -0
- data/doc/Beway.html +185 -0
- data/doc/Beway/Auction.html +802 -0
- data/doc/Beway/AuctionParseError.html +160 -0
- data/doc/Beway/Bidder.html +531 -0
- data/doc/Beway/BidderError.html +160 -0
- data/doc/Beway/CliRunner.html +817 -0
- data/doc/Beway/EbayData.html +453 -0
- data/doc/Beway/EbayDataParseError.html +160 -0
- data/doc/Beway/InvalidUrlError.html +160 -0
- data/doc/README.html +175 -0
- data/doc/created.rid +6 -0
- data/doc/index.html +225 -0
- data/doc/lib/beway/auction_rb.html +56 -0
- data/doc/lib/beway/bidder_rb.html +54 -0
- data/doc/lib/beway/cli_runner_rb.html +52 -0
- data/doc/lib/beway/ebay_data_rb.html +58 -0
- data/doc/rdoc.css +706 -0
- data/lib/beway.rb +4 -0
- data/lib/beway/auction.rb +150 -0
- data/lib/beway/bidder.rb +100 -0
- data/lib/beway/cli_runner.rb +184 -0
- data/lib/beway/ebay_data.rb +66 -0
- data/spec/auction_spec.rb +163 -0
- data/spec/bidder_spec.rb +30 -0
- data/spec/config.rb +4 -0
- data/spec/config.rb-dist +4 -0
- data/spec/ebay_data_spec.rb +23 -0
- data/spec/html/alfani-sweater-complete.html +39 -0
- data/spec/html/cashmere-sweater-complete.html +39 -0
- data/spec/html/cashmere-sweater.html +84 -0
- data/spec/html/mens-cardigans-dutch-bin.html +192 -0
- data/spec/html/pink-sweater-bid-bin.html +68 -0
- data/spec/html/polo-lambs-wool.html +150 -0
- data/spec/html/spring-mercer-bin-mo.html +533 -0
- data/spec/html/xmas-sweater.html +260 -0
- metadata +192 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
jruby-jars (1.5.6)
|
6
|
+
jruby-rack (1.0.4)
|
7
|
+
mechanize (1.0.0)
|
8
|
+
nokogiri (>= 1.2.1)
|
9
|
+
nokogiri (1.4.4)
|
10
|
+
rake (0.8.7)
|
11
|
+
rspec (2.4.0)
|
12
|
+
rspec-core (~> 2.4.0)
|
13
|
+
rspec-expectations (~> 2.4.0)
|
14
|
+
rspec-mocks (~> 2.4.0)
|
15
|
+
rspec-core (2.4.0)
|
16
|
+
rspec-expectations (2.4.0)
|
17
|
+
diff-lcs (~> 1.1.2)
|
18
|
+
rspec-mocks (2.4.0)
|
19
|
+
rubyzip (0.9.4)
|
20
|
+
warbler (1.2.1)
|
21
|
+
jruby-jars (>= 1.4.0)
|
22
|
+
jruby-rack (>= 1.0.0)
|
23
|
+
rake (>= 0.8.7)
|
24
|
+
rubyzip (>= 0.9.4)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
mechanize (>= 1.0.0)
|
31
|
+
nokogiri (>= 1.4.4)
|
32
|
+
rake
|
33
|
+
rspec (>= 2.4.0)
|
34
|
+
warbler (>= 1.2.1)
|
data/README
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
== BEWAY - an ebay sniping tool
|
2
|
+
|
3
|
+
Beway is a small Ruby library that:
|
4
|
+
|
5
|
+
- Retrieves information about an ebay auction
|
6
|
+
- Bids on an ebay auction
|
7
|
+
- Retrieves official ebay time
|
8
|
+
- Offers a simple user interface for bidding on an auction
|
9
|
+
|
10
|
+
== Requirements
|
11
|
+
|
12
|
+
Perhaps not requirements, but developed and tested with the
|
13
|
+
following:
|
14
|
+
|
15
|
+
- Ruby 1.9.2
|
16
|
+
|
17
|
+
And these gems:
|
18
|
+
|
19
|
+
- mechanize (1.0.0)
|
20
|
+
- nokogiri (1.4.4)
|
21
|
+
- rspec (2.4.0)
|
22
|
+
|
23
|
+
== Installation
|
24
|
+
|
25
|
+
Install your gems:
|
26
|
+
|
27
|
+
gem install mechanize rspec nokogiri
|
28
|
+
|
29
|
+
Run the CLI interface
|
30
|
+
|
31
|
+
ruby bin/beway
|
32
|
+
|
33
|
+
== Tests
|
34
|
+
|
35
|
+
Make sure everything works as expected:
|
36
|
+
|
37
|
+
rake spec
|
38
|
+
|
39
|
+
== Docs
|
40
|
+
|
41
|
+
Generate rdoc html:
|
42
|
+
|
43
|
+
rake rdoc
|
data/README.rdoc
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
== BEWAY - an ebay sniping tool
|
2
|
+
|
3
|
+
Beway is a small Ruby library that:
|
4
|
+
|
5
|
+
- Retrieves information about an ebay auction
|
6
|
+
- Bids on an ebay auction
|
7
|
+
- Retrieves official ebay time
|
8
|
+
- Offers a simple user interface for bidding on an auction
|
9
|
+
|
10
|
+
== Requirements
|
11
|
+
|
12
|
+
Perhaps not requirements, but developed and tested with the
|
13
|
+
following:
|
14
|
+
|
15
|
+
- Ruby 1.9.2
|
16
|
+
|
17
|
+
And these gems:
|
18
|
+
|
19
|
+
- mechanize (1.0.0)
|
20
|
+
- nokogiri (1.4.4)
|
21
|
+
- rspec (2.4.0)
|
22
|
+
|
23
|
+
== Installation
|
24
|
+
|
25
|
+
Install your gems:
|
26
|
+
|
27
|
+
gem install mechanize rspec nokogiri
|
28
|
+
|
29
|
+
Run the CLI interface
|
30
|
+
|
31
|
+
ruby bin/beway
|
32
|
+
|
33
|
+
== Tests
|
34
|
+
|
35
|
+
Make sure everything works as expected:
|
36
|
+
|
37
|
+
rake spec
|
38
|
+
|
39
|
+
== Docs
|
40
|
+
|
41
|
+
Generate rdoc html:
|
42
|
+
|
43
|
+
rake rdoc
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "rake/rdoctask"
|
2
|
+
require "rake/gempackagetask"
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
|
5
|
+
task :default => [:spec]
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
Rake::RDocTask.new do |rd|
|
10
|
+
rd.main = "README"
|
11
|
+
rd.rdoc_files.include("README", "lib/beway/*.rb")
|
12
|
+
rd.rdoc_dir = 'doc'
|
13
|
+
end
|
14
|
+
|
15
|
+
gemspec = Gem::Specification.load "beway.gemspec"
|
16
|
+
Rake::GemPackageTask.new(gemspec) do |pkg|
|
17
|
+
pkg.need_zip = true
|
18
|
+
pkg.need_tar = true
|
19
|
+
end
|
data/bin/beway
ADDED
data/doc/Beway.html
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Module: Beway</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="./js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="./js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="./js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body class="module">
|
23
|
+
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="./index.html">Home</a>
|
29
|
+
<a href="./index.html#classes">Classes</a>
|
30
|
+
<a href="./index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="./lib/beway/ebay_data_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/beway/ebay_data.rb">lib/beway/ebay_data.rb</a></li>
|
43
|
+
|
44
|
+
<li><a href="./lib/beway/auction_rb.html?TB_iframe=true&height=550&width=785"
|
45
|
+
class="thickbox" title="lib/beway/auction.rb">lib/beway/auction.rb</a></li>
|
46
|
+
|
47
|
+
<li><a href="./lib/beway/cli_runner_rb.html?TB_iframe=true&height=550&width=785"
|
48
|
+
class="thickbox" title="lib/beway/cli_runner.rb">lib/beway/cli_runner.rb</a></li>
|
49
|
+
|
50
|
+
<li><a href="./lib/beway/bidder_rb.html?TB_iframe=true&height=550&width=785"
|
51
|
+
class="thickbox" title="lib/beway/bidder.rb">lib/beway/bidder.rb</a></li>
|
52
|
+
|
53
|
+
</ul>
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<div id="class-metadata">
|
61
|
+
|
62
|
+
<!-- Parent Class -->
|
63
|
+
|
64
|
+
|
65
|
+
<!-- Namespace Contents -->
|
66
|
+
|
67
|
+
<div id="namespace-list-section" class="section">
|
68
|
+
<h3 class="section-header">Namespace</h3>
|
69
|
+
<ul class="link-list">
|
70
|
+
|
71
|
+
<li><span class="type">CLASS</span> <a href="Beway/Auction.html">Beway::Auction</a></li>
|
72
|
+
|
73
|
+
<li><span class="type">CLASS</span> <a href="Beway/AuctionParseError.html">Beway::AuctionParseError</a></li>
|
74
|
+
|
75
|
+
<li><span class="type">CLASS</span> <a href="Beway/Bidder.html">Beway::Bidder</a></li>
|
76
|
+
|
77
|
+
<li><span class="type">CLASS</span> <a href="Beway/BidderError.html">Beway::BidderError</a></li>
|
78
|
+
|
79
|
+
<li><span class="type">CLASS</span> <a href="Beway/CliRunner.html">Beway::CliRunner</a></li>
|
80
|
+
|
81
|
+
<li><span class="type">CLASS</span> <a href="Beway/EbayData.html">Beway::EbayData</a></li>
|
82
|
+
|
83
|
+
<li><span class="type">CLASS</span> <a href="Beway/EbayDataParseError.html">Beway::EbayDataParseError</a></li>
|
84
|
+
|
85
|
+
<li><span class="type">CLASS</span> <a href="Beway/InvalidUrlError.html">Beway::InvalidUrlError</a></li>
|
86
|
+
|
87
|
+
</ul>
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
<!-- Method Quickref -->
|
92
|
+
|
93
|
+
|
94
|
+
<!-- Included Modules -->
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
<div id="project-metadata">
|
99
|
+
|
100
|
+
|
101
|
+
<div id="fileindex-section" class="section project-section">
|
102
|
+
<h3 class="section-header">Files</h3>
|
103
|
+
<ul>
|
104
|
+
|
105
|
+
<li class="file"><a href="./README.html">README</a></li>
|
106
|
+
|
107
|
+
</ul>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
|
111
|
+
<div id="classindex-section" class="section project-section">
|
112
|
+
<h3 class="section-header">Class Index
|
113
|
+
<span class="search-toggle"><img src="./images/find.png"
|
114
|
+
height="16" width="16" alt="[+]"
|
115
|
+
title="show/hide quicksearch" /></span></h3>
|
116
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
117
|
+
<fieldset>
|
118
|
+
<legend>Quicksearch</legend>
|
119
|
+
<input type="text" name="quicksearch" value=""
|
120
|
+
class="quicksearch-field" />
|
121
|
+
</fieldset>
|
122
|
+
</form>
|
123
|
+
|
124
|
+
<ul class="link-list">
|
125
|
+
|
126
|
+
<li><a href="./Beway.html">Beway</a></li>
|
127
|
+
|
128
|
+
<li><a href="./Beway/Auction.html">Beway::Auction</a></li>
|
129
|
+
|
130
|
+
<li><a href="./Beway/AuctionParseError.html">Beway::AuctionParseError</a></li>
|
131
|
+
|
132
|
+
<li><a href="./Beway/Bidder.html">Beway::Bidder</a></li>
|
133
|
+
|
134
|
+
<li><a href="./Beway/BidderError.html">Beway::BidderError</a></li>
|
135
|
+
|
136
|
+
<li><a href="./Beway/CliRunner.html">Beway::CliRunner</a></li>
|
137
|
+
|
138
|
+
<li><a href="./Beway/EbayData.html">Beway::EbayData</a></li>
|
139
|
+
|
140
|
+
<li><a href="./Beway/EbayDataParseError.html">Beway::EbayDataParseError</a></li>
|
141
|
+
|
142
|
+
<li><a href="./Beway/InvalidUrlError.html">Beway::InvalidUrlError</a></li>
|
143
|
+
|
144
|
+
</ul>
|
145
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
146
|
+
</div>
|
147
|
+
|
148
|
+
|
149
|
+
</div>
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<div id="documentation">
|
153
|
+
<h1 class="module">Beway</h1>
|
154
|
+
|
155
|
+
<div id="description">
|
156
|
+
|
157
|
+
</div>
|
158
|
+
|
159
|
+
<!-- Constants -->
|
160
|
+
|
161
|
+
|
162
|
+
<!-- Attributes -->
|
163
|
+
|
164
|
+
|
165
|
+
<!-- Methods -->
|
166
|
+
|
167
|
+
|
168
|
+
</div>
|
169
|
+
|
170
|
+
|
171
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
172
|
+
|
173
|
+
<p>Disabled; run with --debug to generate this.</p>
|
174
|
+
|
175
|
+
</div>
|
176
|
+
|
177
|
+
<div id="validator-badges">
|
178
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
179
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
180
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
</body>
|
184
|
+
</html>
|
185
|
+
|
@@ -0,0 +1,802 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: Beway::Auction</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="../js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="../js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="../js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body class="class">
|
23
|
+
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="../index.html">Home</a>
|
29
|
+
<a href="../index.html#classes">Classes</a>
|
30
|
+
<a href="../index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="../lib/beway/auction_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/beway/auction.rb">lib/beway/auction.rb</a></li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div id="class-metadata">
|
52
|
+
|
53
|
+
<!-- Parent Class -->
|
54
|
+
|
55
|
+
<div id="parent-class-section" class="section">
|
56
|
+
<h3 class="section-header">Parent</h3>
|
57
|
+
|
58
|
+
<p class="link">Object</p>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Namespace Contents -->
|
64
|
+
|
65
|
+
|
66
|
+
<!-- Method Quickref -->
|
67
|
+
|
68
|
+
<div id="method-list-section" class="section">
|
69
|
+
<h3 class="section-header">Methods</h3>
|
70
|
+
<ul class="link-list">
|
71
|
+
|
72
|
+
<li><a href="#method-c-new">::new</a></li>
|
73
|
+
|
74
|
+
<li><a href="#method-i-auction_number">#auction_number</a></li>
|
75
|
+
|
76
|
+
<li><a href="#method-i-complete%3F">#complete?</a></li>
|
77
|
+
|
78
|
+
<li><a href="#method-i-current_bid">#current_bid</a></li>
|
79
|
+
|
80
|
+
<li><a href="#method-i-description">#description</a></li>
|
81
|
+
|
82
|
+
<li><a href="#method-i-end_time">#end_time</a></li>
|
83
|
+
|
84
|
+
<li><a href="#method-i-has_bid_button%3F">#has_bid_button?</a></li>
|
85
|
+
|
86
|
+
<li><a href="#method-i-min_bid">#min_bid</a></li>
|
87
|
+
|
88
|
+
<li><a href="#method-i-node_text">#node_text</a></li>
|
89
|
+
|
90
|
+
<li><a href="#method-i-refresh_doc">#refresh_doc</a></li>
|
91
|
+
|
92
|
+
<li><a href="#method-i-time_left">#time_left</a></li>
|
93
|
+
|
94
|
+
<li><a href="#method-i-time_node">#time_node</a></li>
|
95
|
+
|
96
|
+
<li><a href="#method-i-valid_auction%3F">#valid_auction?</a></li>
|
97
|
+
|
98
|
+
</ul>
|
99
|
+
</div>
|
100
|
+
|
101
|
+
|
102
|
+
<!-- Included Modules -->
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
<div id="project-metadata">
|
107
|
+
|
108
|
+
|
109
|
+
<div id="fileindex-section" class="section project-section">
|
110
|
+
<h3 class="section-header">Files</h3>
|
111
|
+
<ul>
|
112
|
+
|
113
|
+
<li class="file"><a href="../README.html">README</a></li>
|
114
|
+
|
115
|
+
</ul>
|
116
|
+
</div>
|
117
|
+
|
118
|
+
|
119
|
+
<div id="classindex-section" class="section project-section">
|
120
|
+
<h3 class="section-header">Class Index
|
121
|
+
<span class="search-toggle"><img src="../images/find.png"
|
122
|
+
height="16" width="16" alt="[+]"
|
123
|
+
title="show/hide quicksearch" /></span></h3>
|
124
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
125
|
+
<fieldset>
|
126
|
+
<legend>Quicksearch</legend>
|
127
|
+
<input type="text" name="quicksearch" value=""
|
128
|
+
class="quicksearch-field" />
|
129
|
+
</fieldset>
|
130
|
+
</form>
|
131
|
+
|
132
|
+
<ul class="link-list">
|
133
|
+
|
134
|
+
<li><a href="../Beway.html">Beway</a></li>
|
135
|
+
|
136
|
+
<li><a href="../Beway/Auction.html">Beway::Auction</a></li>
|
137
|
+
|
138
|
+
<li><a href="../Beway/AuctionParseError.html">Beway::AuctionParseError</a></li>
|
139
|
+
|
140
|
+
<li><a href="../Beway/Bidder.html">Beway::Bidder</a></li>
|
141
|
+
|
142
|
+
<li><a href="../Beway/BidderError.html">Beway::BidderError</a></li>
|
143
|
+
|
144
|
+
<li><a href="../Beway/CliRunner.html">Beway::CliRunner</a></li>
|
145
|
+
|
146
|
+
<li><a href="../Beway/EbayData.html">Beway::EbayData</a></li>
|
147
|
+
|
148
|
+
<li><a href="../Beway/EbayDataParseError.html">Beway::EbayDataParseError</a></li>
|
149
|
+
|
150
|
+
<li><a href="../Beway/InvalidUrlError.html">Beway::InvalidUrlError</a></li>
|
151
|
+
|
152
|
+
</ul>
|
153
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div id="documentation">
|
161
|
+
<h1 class="class">Beway::Auction</h1>
|
162
|
+
|
163
|
+
<div id="description">
|
164
|
+
<p>
|
165
|
+
<a href="Auction.html">Auction</a>
|
166
|
+
</p>
|
167
|
+
<p>
|
168
|
+
Represents an ebay auction. Can only be instantiated for true auctions (no
|
169
|
+
buy-it-now-only sales) and completed auctions.
|
170
|
+
</p>
|
171
|
+
|
172
|
+
</div>
|
173
|
+
|
174
|
+
<!-- Constants -->
|
175
|
+
|
176
|
+
|
177
|
+
<!-- Attributes -->
|
178
|
+
|
179
|
+
<div id="attribute-method-details" class="method-section section">
|
180
|
+
<h3 class="section-header">Attributes</h3>
|
181
|
+
|
182
|
+
|
183
|
+
<div id="url-attribute-method" class="method-detail">
|
184
|
+
<a name="url"></a>
|
185
|
+
|
186
|
+
<div class="method-heading attribute-method-heading">
|
187
|
+
<span class="method-name">url</span><span
|
188
|
+
class="attribute-access-type">[R]</span>
|
189
|
+
</div>
|
190
|
+
|
191
|
+
<div class="method-description">
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
|
198
|
+
<div id="doc-attribute-method" class="method-detail">
|
199
|
+
<a name="doc"></a>
|
200
|
+
|
201
|
+
<div class="method-heading attribute-method-heading">
|
202
|
+
<span class="method-name">doc</span><span
|
203
|
+
class="attribute-access-type">[R]</span>
|
204
|
+
</div>
|
205
|
+
|
206
|
+
<div class="method-description">
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
</div>
|
211
|
+
</div>
|
212
|
+
|
213
|
+
<div id="last-updated-attribute-method" class="method-detail">
|
214
|
+
<a name="last_updated"></a>
|
215
|
+
|
216
|
+
<div class="method-heading attribute-method-heading">
|
217
|
+
<span class="method-name">last_updated</span><span
|
218
|
+
class="attribute-access-type">[R]</span>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
<div class="method-description">
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
</div>
|
226
|
+
</div>
|
227
|
+
|
228
|
+
</div>
|
229
|
+
|
230
|
+
|
231
|
+
<!-- Methods -->
|
232
|
+
|
233
|
+
<div id="public-class-method-details" class="method-section section">
|
234
|
+
<h3 class="section-header">Public Class Methods</h3>
|
235
|
+
|
236
|
+
|
237
|
+
<div id="new-method" class="method-detail ">
|
238
|
+
<a name="method-c-new"></a>
|
239
|
+
|
240
|
+
<div class="method-heading">
|
241
|
+
|
242
|
+
<span class="method-name">new</span><span
|
243
|
+
class="method-args">(url)</span>
|
244
|
+
<span class="method-click-advice">click to toggle source</span>
|
245
|
+
|
246
|
+
</div>
|
247
|
+
|
248
|
+
<div class="method-description">
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
<div class="method-source-code"
|
255
|
+
id="new-source">
|
256
|
+
<pre>
|
257
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 16</span>
|
258
|
+
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">url</span>
|
259
|
+
17: <span class="ruby-ivar">@url</span> = <span class="ruby-identifier">url</span>
|
260
|
+
18: <span class="ruby-identifier">refresh_doc</span>
|
261
|
+
19: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidUrlError</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid_auction?</span>
|
262
|
+
20: <span class="ruby-keyword kw">end</span></pre>
|
263
|
+
</div>
|
264
|
+
|
265
|
+
</div>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
</div>
|
271
|
+
|
272
|
+
|
273
|
+
</div>
|
274
|
+
|
275
|
+
<div id="public-instance-method-details" class="method-section section">
|
276
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
277
|
+
|
278
|
+
|
279
|
+
<div id="auction-number-method" class="method-detail ">
|
280
|
+
<a name="method-i-auction_number"></a>
|
281
|
+
|
282
|
+
<div class="method-heading">
|
283
|
+
|
284
|
+
<span class="method-name">auction_number</span><span
|
285
|
+
class="method-args">()</span>
|
286
|
+
<span class="method-click-advice">click to toggle source</span>
|
287
|
+
|
288
|
+
</div>
|
289
|
+
|
290
|
+
<div class="method-description">
|
291
|
+
|
292
|
+
<p>
|
293
|
+
parsing method, returns a string
|
294
|
+
</p>
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
<div class="method-source-code"
|
299
|
+
id="auction-number-source">
|
300
|
+
<pre>
|
301
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 112</span>
|
302
|
+
112: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">auction_number</span>
|
303
|
+
113: <span class="ruby-identifier">canonical_url_node</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">at_css</span>(<span class="ruby-value str">'link[@rel = "canonical"]'</span>)
|
304
|
+
114: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Couldn't find canonical URL"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">canonical_url_node</span>
|
305
|
+
115: <span class="ruby-identifier">canonical_url_node</span>.<span class="ruby-identifier">attr</span>(<span class="ruby-value str">'href'</span>)[<span class="ruby-regexp re">/\d+$/</span>]
|
306
|
+
116: <span class="ruby-keyword kw">end</span></pre>
|
307
|
+
</div>
|
308
|
+
|
309
|
+
</div>
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
</div>
|
315
|
+
|
316
|
+
|
317
|
+
<div id="complete--method" class="method-detail ">
|
318
|
+
<a name="method-i-complete%3F"></a>
|
319
|
+
|
320
|
+
<div class="method-heading">
|
321
|
+
|
322
|
+
<span class="method-name">complete?</span><span
|
323
|
+
class="method-args">()</span>
|
324
|
+
<span class="method-click-advice">click to toggle source</span>
|
325
|
+
|
326
|
+
</div>
|
327
|
+
|
328
|
+
<div class="method-description">
|
329
|
+
|
330
|
+
<p>
|
331
|
+
has bidding ended yet?
|
332
|
+
</p>
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
<div class="method-source-code"
|
337
|
+
id="complete--source">
|
338
|
+
<pre>
|
339
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 29</span>
|
340
|
+
29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">complete?</span>
|
341
|
+
30: <span class="ruby-identifier">complete_span</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">at_xpath</span>(<span class="ruby-value str">'//span[contains(text(), "Bidding has ended on this item")]'</span>)
|
342
|
+
31: <span class="ruby-keyword kw">return</span> (<span class="ruby-identifier">complete_span</span>.<span class="ruby-identifier">nil?</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">false</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">true</span>
|
343
|
+
32: <span class="ruby-keyword kw">end</span></pre>
|
344
|
+
</div>
|
345
|
+
|
346
|
+
</div>
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
</div>
|
352
|
+
|
353
|
+
|
354
|
+
<div id="current-bid-method" class="method-detail ">
|
355
|
+
<a name="method-i-current_bid"></a>
|
356
|
+
|
357
|
+
<div class="method-heading">
|
358
|
+
|
359
|
+
<span class="method-name">current_bid</span><span
|
360
|
+
class="method-args">()</span>
|
361
|
+
<span class="method-click-advice">click to toggle source</span>
|
362
|
+
|
363
|
+
</div>
|
364
|
+
|
365
|
+
<div class="method-description">
|
366
|
+
|
367
|
+
<p>
|
368
|
+
parsing method, returns a string
|
369
|
+
</p>
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
<div class="method-source-code"
|
374
|
+
id="current-bid-source">
|
375
|
+
<pre>
|
376
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 41</span>
|
377
|
+
41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">current_bid</span>
|
378
|
+
42: <span class="ruby-comment cmt"># list of ways to get the bid.</span>
|
379
|
+
43: <span class="ruby-identifier">xpaths</span> = [
|
380
|
+
44: <span class="ruby-value str">"//th[contains(text(),'Current bid:')]"</span>,
|
381
|
+
45: <span class="ruby-value str">"//th[contains(text(),'Starting bid:')]"</span>,
|
382
|
+
46: <span class="ruby-value str">"//th[contains(text(),'Price:')]"</span>,
|
383
|
+
47: <span class="ruby-value str">"//td[contains(text(),'Starting bid:')]"</span>,
|
384
|
+
48: <span class="ruby-value str">"//td[contains(text(),'Winning bid:')]"</span>,
|
385
|
+
49: ]
|
386
|
+
50:
|
387
|
+
51: <span class="ruby-identifier">bid_node</span> = <span class="ruby-identifier">xpaths</span>.<span class="ruby-identifier">reduce</span>(<span class="ruby-keyword kw">nil</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">node</span>, <span class="ruby-identifier">xpath</span><span class="ruby-operator">|</span>
|
388
|
+
52: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">nil?</span>
|
389
|
+
53: <span class="ruby-identifier">node</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">at_xpath</span>(<span class="ruby-identifier">xpath</span>)
|
390
|
+
54: <span class="ruby-identifier">node</span> = <span class="ruby-identifier">node</span>.<span class="ruby-identifier">next_sibling</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">nil?</span>
|
391
|
+
55: <span class="ruby-keyword kw">end</span>
|
392
|
+
56: <span class="ruby-identifier">node</span>
|
393
|
+
57: <span class="ruby-keyword kw">end</span>
|
394
|
+
58:
|
395
|
+
59: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Couldn't find current/starting bid header in document"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">bid_node</span>.<span class="ruby-identifier">nil?</span>
|
396
|
+
60: <span class="ruby-identifier">bid_text</span> = <span class="ruby-identifier">node_text</span>(<span class="ruby-identifier">bid_node</span>)
|
397
|
+
61: <span class="ruby-identifier">bid_text</span> = <span class="ruby-identifier">bid_text</span>[<span class="ruby-regexp re">/^[^\[]+/</span>].<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">complete?</span>
|
398
|
+
62: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">bid_text</span>
|
399
|
+
63: <span class="ruby-keyword kw">end</span></pre>
|
400
|
+
</div>
|
401
|
+
|
402
|
+
</div>
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
</div>
|
408
|
+
|
409
|
+
|
410
|
+
<div id="description-method" class="method-detail ">
|
411
|
+
<a name="method-i-description"></a>
|
412
|
+
|
413
|
+
<div class="method-heading">
|
414
|
+
|
415
|
+
<span class="method-name">description</span><span
|
416
|
+
class="method-args">()</span>
|
417
|
+
<span class="method-click-advice">click to toggle source</span>
|
418
|
+
|
419
|
+
</div>
|
420
|
+
|
421
|
+
<div class="method-description">
|
422
|
+
|
423
|
+
<p>
|
424
|
+
parsing method, returns a string
|
425
|
+
</p>
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
<div class="method-source-code"
|
430
|
+
id="description-source">
|
431
|
+
<pre>
|
432
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 66</span>
|
433
|
+
66: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">description</span>
|
434
|
+
67: <span class="ruby-identifier">desc</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">at_css</span>(<span class="ruby-value str">'b#mainContent h1'</span>)
|
435
|
+
68: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Couldn't find description in document"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">desc</span>.<span class="ruby-identifier">nil?</span>
|
436
|
+
69: <span class="ruby-identifier">desc</span>.<span class="ruby-identifier">inner_text</span>.<span class="ruby-identifier">strip</span>
|
437
|
+
70: <span class="ruby-keyword kw">end</span></pre>
|
438
|
+
</div>
|
439
|
+
|
440
|
+
</div>
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
</div>
|
446
|
+
|
447
|
+
|
448
|
+
<div id="end-time-method" class="method-detail ">
|
449
|
+
<a name="method-i-end_time"></a>
|
450
|
+
|
451
|
+
<div class="method-heading">
|
452
|
+
|
453
|
+
<span class="method-name">end_time</span><span
|
454
|
+
class="method-args">()</span>
|
455
|
+
<span class="method-click-advice">click to toggle source</span>
|
456
|
+
|
457
|
+
</div>
|
458
|
+
|
459
|
+
<div class="method-description">
|
460
|
+
|
461
|
+
<p>
|
462
|
+
parsing method, returns a Time object
|
463
|
+
</p>
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
<div class="method-source-code"
|
468
|
+
id="end-time-source">
|
469
|
+
<pre>
|
470
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 99</span>
|
471
|
+
99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_time</span>
|
472
|
+
100: <span class="ruby-identifier">text</span> = <span class="ruby-identifier">node_text</span>(<span class="ruby-identifier">time_node</span>)
|
473
|
+
101: <span class="ruby-identifier">md</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/\(([^)]*)\)/</span>)
|
474
|
+
102: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">md</span>
|
475
|
+
103: <span class="ruby-identifier">time_str</span> = <span class="ruby-identifier">md</span>[<span class="ruby-value">1</span>]
|
476
|
+
104: <span class="ruby-keyword kw">else</span>
|
477
|
+
105: <span class="ruby-identifier">time_str</span> = <span class="ruby-identifier">text</span>
|
478
|
+
106: <span class="ruby-keyword kw">end</span>
|
479
|
+
107: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">time_str</span>
|
480
|
+
108: <span class="ruby-constant">Time</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">time_str</span>)
|
481
|
+
109: <span class="ruby-keyword kw">end</span></pre>
|
482
|
+
</div>
|
483
|
+
|
484
|
+
</div>
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
</div>
|
490
|
+
|
491
|
+
|
492
|
+
<div id="has-bid-button--method" class="method-detail ">
|
493
|
+
<a name="method-i-has_bid_button%3F"></a>
|
494
|
+
|
495
|
+
<div class="method-heading">
|
496
|
+
|
497
|
+
<span class="method-name">has_bid_button?</span><span
|
498
|
+
class="method-args">()</span>
|
499
|
+
<span class="method-click-advice">click to toggle source</span>
|
500
|
+
|
501
|
+
</div>
|
502
|
+
|
503
|
+
<div class="method-description">
|
504
|
+
|
505
|
+
<p>
|
506
|
+
parsming method, returns boolean
|
507
|
+
</p>
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
<div class="method-source-code"
|
512
|
+
id="has-bid-button--source">
|
513
|
+
<pre>
|
514
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 119</span>
|
515
|
+
119: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_bid_button?</span>
|
516
|
+
120: <span class="ruby-identifier">place_bid_button</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">at_xpath</span>(<span class="ruby-value str">'//form//input[@value="Place bid"]'</span>)
|
517
|
+
121: <span class="ruby-keyword kw">return</span> (<span class="ruby-identifier">place_bid_button</span>.<span class="ruby-identifier">nil?</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">false</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">true</span>
|
518
|
+
122: <span class="ruby-keyword kw">end</span></pre>
|
519
|
+
</div>
|
520
|
+
|
521
|
+
</div>
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
</div>
|
527
|
+
|
528
|
+
|
529
|
+
<div id="min-bid-method" class="method-detail ">
|
530
|
+
<a name="method-i-min_bid"></a>
|
531
|
+
|
532
|
+
<div class="method-heading">
|
533
|
+
|
534
|
+
<span class="method-name">min_bid</span><span
|
535
|
+
class="method-args">()</span>
|
536
|
+
<span class="method-click-advice">click to toggle source</span>
|
537
|
+
|
538
|
+
</div>
|
539
|
+
|
540
|
+
<div class="method-description">
|
541
|
+
|
542
|
+
<p>
|
543
|
+
parsing method, returns a float
|
544
|
+
</p>
|
545
|
+
|
546
|
+
|
547
|
+
|
548
|
+
<div class="method-source-code"
|
549
|
+
id="min-bid-source">
|
550
|
+
<pre>
|
551
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 86</span>
|
552
|
+
86: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">min_bid</span>
|
553
|
+
87: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">complete?</span>
|
554
|
+
88:
|
555
|
+
89: <span class="ruby-identifier">max_label</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">at_xpath</span>(<span class="ruby-value str">"//th/label[contains(text(),'Your max bid:')]"</span>)
|
556
|
+
90: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Couldn't find max bid label in document"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">max_label</span>
|
557
|
+
91: <span class="ruby-identifier">min_bid_node</span> = <span class="ruby-identifier">max_label</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">next_sibling</span>
|
558
|
+
92: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Couldn't find minimum bid in document"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">min_bid_node</span>
|
559
|
+
93: <span class="ruby-identifier">md</span> = <span class="ruby-regexp re">/\(Enter ([^)]*) or more\)/</span>.<span class="ruby-identifier">match</span> <span class="ruby-identifier">min_bid_node</span>.<span class="ruby-identifier">inner_text</span>
|
560
|
+
94: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Min Bid data not in expected format"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">md</span>.<span class="ruby-identifier">nil?</span>
|
561
|
+
95: <span class="ruby-identifier">md</span>[<span class="ruby-value">1</span>][<span class="ruby-regexp re">/\d*\.\d*/</span>].<span class="ruby-identifier">to_f</span>
|
562
|
+
96: <span class="ruby-keyword kw">end</span></pre>
|
563
|
+
</div>
|
564
|
+
|
565
|
+
</div>
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
|
570
|
+
</div>
|
571
|
+
|
572
|
+
|
573
|
+
<div id="refresh-doc-method" class="method-detail ">
|
574
|
+
<a name="method-i-refresh_doc"></a>
|
575
|
+
|
576
|
+
<div class="method-heading">
|
577
|
+
|
578
|
+
<span class="method-name">refresh_doc</span><span
|
579
|
+
class="method-args">()</span>
|
580
|
+
<span class="method-click-advice">click to toggle source</span>
|
581
|
+
|
582
|
+
</div>
|
583
|
+
|
584
|
+
<div class="method-description">
|
585
|
+
|
586
|
+
<p>
|
587
|
+
fetch the url again
|
588
|
+
</p>
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
<div class="method-source-code"
|
593
|
+
id="refresh-doc-source">
|
594
|
+
<pre>
|
595
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 35</span>
|
596
|
+
35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">refresh_doc</span>
|
597
|
+
36: <span class="ruby-ivar">@doc</span> = <span class="ruby-constant">Nokogiri</span><span class="ruby-operator">::</span><span class="ruby-constant">HTML</span>(<span class="ruby-identifier">open</span>(<span class="ruby-ivar">@url</span>))
|
598
|
+
37: <span class="ruby-ivar">@last_updated</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
599
|
+
38: <span class="ruby-keyword kw">end</span></pre>
|
600
|
+
</div>
|
601
|
+
|
602
|
+
</div>
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
</div>
|
608
|
+
|
609
|
+
|
610
|
+
<div id="time-left-method" class="method-detail ">
|
611
|
+
<a name="method-i-time_left"></a>
|
612
|
+
|
613
|
+
<div class="method-heading">
|
614
|
+
|
615
|
+
<span class="method-name">time_left</span><span
|
616
|
+
class="method-args">()</span>
|
617
|
+
<span class="method-click-advice">click to toggle source</span>
|
618
|
+
|
619
|
+
</div>
|
620
|
+
|
621
|
+
<div class="method-description">
|
622
|
+
|
623
|
+
<p>
|
624
|
+
parsing method, returns a string
|
625
|
+
</p>
|
626
|
+
|
627
|
+
|
628
|
+
|
629
|
+
<div class="method-source-code"
|
630
|
+
id="time-left-source">
|
631
|
+
<pre>
|
632
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 73</span>
|
633
|
+
73: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">time_left</span>
|
634
|
+
74: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">complete?</span>
|
635
|
+
75:
|
636
|
+
76: <span class="ruby-identifier">time_str</span> = <span class="ruby-identifier">node_text</span>(<span class="ruby-identifier">time_node</span>)
|
637
|
+
77: <span class="ruby-identifier">time_str</span> = <span class="ruby-identifier">time_str</span>[<span class="ruby-regexp re">/^[^(]*/</span>].<span class="ruby-identifier">strip</span>
|
638
|
+
78: <span class="ruby-identifier">time_ar</span> = <span class="ruby-identifier">time_str</span>.<span class="ruby-identifier">split</span>
|
639
|
+
79: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Didn't find hour marker where expected"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">time_ar</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'h'</span>
|
640
|
+
80: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Didn't find minute marker where expected"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">time_ar</span>[<span class="ruby-value">3</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'m'</span>
|
641
|
+
81: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Didn't find second marker where expected"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">time_ar</span>[<span class="ruby-value">5</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'s'</span>
|
642
|
+
82: <span class="ruby-identifier">time_ar</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">'h '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">time_ar</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">'m '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">time_ar</span>[<span class="ruby-value">4</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">'s'</span>
|
643
|
+
83: <span class="ruby-keyword kw">end</span></pre>
|
644
|
+
</div>
|
645
|
+
|
646
|
+
</div>
|
647
|
+
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
</div>
|
652
|
+
|
653
|
+
|
654
|
+
<div id="valid-auction--method" class="method-detail ">
|
655
|
+
<a name="method-i-valid_auction%3F"></a>
|
656
|
+
|
657
|
+
<div class="method-heading">
|
658
|
+
|
659
|
+
<span class="method-name">valid_auction?</span><span
|
660
|
+
class="method-args">()</span>
|
661
|
+
<span class="method-click-advice">click to toggle source</span>
|
662
|
+
|
663
|
+
</div>
|
664
|
+
|
665
|
+
<div class="method-description">
|
666
|
+
|
667
|
+
<p>
|
668
|
+
can we represent this auction?
|
669
|
+
</p>
|
670
|
+
|
671
|
+
|
672
|
+
|
673
|
+
<div class="method-source-code"
|
674
|
+
id="valid-auction--source">
|
675
|
+
<pre>
|
676
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 23</span>
|
677
|
+
23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">valid_auction?</span>
|
678
|
+
24: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">complete?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">has_bid_button?</span>
|
679
|
+
25: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
680
|
+
26: <span class="ruby-keyword kw">end</span></pre>
|
681
|
+
</div>
|
682
|
+
|
683
|
+
</div>
|
684
|
+
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
</div>
|
689
|
+
|
690
|
+
|
691
|
+
</div>
|
692
|
+
|
693
|
+
<div id="private-instance-method-details" class="method-section section">
|
694
|
+
<h3 class="section-header">Private Instance Methods</h3>
|
695
|
+
|
696
|
+
|
697
|
+
<div id="node-text-method" class="method-detail ">
|
698
|
+
<a name="method-i-node_text"></a>
|
699
|
+
|
700
|
+
<div class="method-heading">
|
701
|
+
|
702
|
+
<span class="method-name">node_text</span><span
|
703
|
+
class="method-args">(n)</span>
|
704
|
+
<span class="method-click-advice">click to toggle source</span>
|
705
|
+
|
706
|
+
</div>
|
707
|
+
|
708
|
+
<div class="method-description">
|
709
|
+
|
710
|
+
<p>
|
711
|
+
a string of all text nodes below n, concatenated
|
712
|
+
</p>
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
<div class="method-source-code"
|
717
|
+
id="node-text-source">
|
718
|
+
<pre>
|
719
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 143</span>
|
720
|
+
143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">node_text</span>(<span class="ruby-identifier">n</span>)
|
721
|
+
144: <span class="ruby-identifier">t</span> = <span class="ruby-value str">''</span>
|
722
|
+
145: <span class="ruby-identifier">n</span>.<span class="ruby-identifier">traverse</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">t</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">' '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">text?</span> }
|
723
|
+
146: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/ +/</span>, <span class="ruby-value str">' '</span>).<span class="ruby-identifier">strip</span>
|
724
|
+
147: <span class="ruby-keyword kw">end</span></pre>
|
725
|
+
</div>
|
726
|
+
|
727
|
+
</div>
|
728
|
+
|
729
|
+
|
730
|
+
|
731
|
+
|
732
|
+
</div>
|
733
|
+
|
734
|
+
|
735
|
+
<div id="time-node-method" class="method-detail ">
|
736
|
+
<a name="method-i-time_node"></a>
|
737
|
+
|
738
|
+
<div class="method-heading">
|
739
|
+
|
740
|
+
<span class="method-name">time_node</span><span
|
741
|
+
class="method-args">()</span>
|
742
|
+
<span class="method-click-advice">click to toggle source</span>
|
743
|
+
|
744
|
+
</div>
|
745
|
+
|
746
|
+
<div class="method-description">
|
747
|
+
|
748
|
+
<p>
|
749
|
+
fetch the node containing the end time
|
750
|
+
</p>
|
751
|
+
|
752
|
+
|
753
|
+
|
754
|
+
<div class="method-source-code"
|
755
|
+
id="time-node-source">
|
756
|
+
<pre>
|
757
|
+
<span class="ruby-comment cmt"># File lib/beway/auction.rb, line 127</span>
|
758
|
+
127: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">time_node</span>
|
759
|
+
128: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">complete?</span>
|
760
|
+
129: <span class="ruby-identifier">td</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">at_xpath</span>(<span class="ruby-value str">"//td[contains(text(),'Ended:')]"</span>)
|
761
|
+
130: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Couldn't find ended header"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">td</span>
|
762
|
+
131: <span class="ruby-identifier">node</span> = <span class="ruby-identifier">td</span>.<span class="ruby-identifier">next_sibling</span>
|
763
|
+
132: <span class="ruby-keyword kw">else</span>
|
764
|
+
133: <span class="ruby-identifier">th</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">at_xpath</span>(<span class="ruby-value str">"//th[contains(text(),'Time left:')]"</span>)
|
765
|
+
134: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Couldn't find Time Left header"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">th</span>
|
766
|
+
135: <span class="ruby-identifier">node</span> = <span class="ruby-identifier">th</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">at_css</span>(<span class="ruby-value str">'td'</span>)
|
767
|
+
136: <span class="ruby-keyword kw">end</span>
|
768
|
+
137:
|
769
|
+
138: <span class="ruby-identifier">raise</span> <span class="ruby-constant">AuctionParseError</span>, <span class="ruby-value str">"Couldn't find Time node"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">node</span>
|
770
|
+
139: <span class="ruby-identifier">node</span>
|
771
|
+
140: <span class="ruby-keyword kw">end</span></pre>
|
772
|
+
</div>
|
773
|
+
|
774
|
+
</div>
|
775
|
+
|
776
|
+
|
777
|
+
|
778
|
+
|
779
|
+
</div>
|
780
|
+
|
781
|
+
|
782
|
+
</div>
|
783
|
+
|
784
|
+
|
785
|
+
</div>
|
786
|
+
|
787
|
+
|
788
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
789
|
+
|
790
|
+
<p>Disabled; run with --debug to generate this.</p>
|
791
|
+
|
792
|
+
</div>
|
793
|
+
|
794
|
+
<div id="validator-badges">
|
795
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
796
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
797
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
798
|
+
</div>
|
799
|
+
|
800
|
+
</body>
|
801
|
+
</html>
|
802
|
+
|