Class: Fight
Instance Method Summary collapse
- #contestants ⇒ Object
- #fight! ⇒ Object
-
#initialize ⇒ Fight
constructor
A new instance of Fight.
- #process_options ⇒ Object
Constructor Details
#initialize ⇒ Fight
Returns a new instance of Fight.
5 6 7 8 |
# File 'lib/fight.rb', line 5 def initialize fight! end |
Instance Method Details
#contestants ⇒ Object
12 13 14 |
# File 'lib/fight.rb', line 12 def contestants ARGV.to_a end |
#fight! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fight.rb', line 15 def fight! contestants.collect do |contestant| contestant = %{"#{contestant}"} if @quote page = open(url_for(contestant)).read match = page.match(pattern) count = match ? match[1] : '0' [count, contestant] end.sort_by {|result| result[0].gsub(',', '').to_i}.reverse.each do |result| puts result * ' -- ' end end |
#process_options ⇒ Object
9 10 11 |
# File 'lib/fight.rb', line 9 def @quote = !!ARGV.delete("-q") end |