Class: WeatherFunds::ResultSet

Inherits:
Object
  • Object
show all
Defined in:
lib/weather_funds/result_set.rb

Direct Known Subclasses

Lightning, Sunshine

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Constructor Details

#initialize(result_tag, winner_tag) ⇒ ResultSet

Returns a new instance of ResultSet.



7
8
9
10
11
# File 'lib/weather_funds/result_set.rb', line 7

def initialize(result_tag, winner_tag)
  @result_tag = result_tag
  @winner_tag = winner_tag
  @data       = Nokogiri::XML(open("http://weatherfunds.co.uk/windata.xml"))
end

Instance Method Details

#dateObject



13
14
15
# File 'lib/weather_funds/result_set.rb', line 13

def date
  @data.css('wl').first['wdate']
end

#find(name) ⇒ Object



25
26
27
# File 'lib/weather_funds/result_set.rb', line 25

def find(name)
  @lotteries.select { |lottery| lottery.name == name }[0]
end

#find_by_scheme(scheme) ⇒ Object



29
30
31
# File 'lib/weather_funds/result_set.rb', line 29

def find_by_scheme(scheme)
  @lotteries.select { |lottery| lottery.scheme == scheme }[0]
end

#lotteriesObject



21
22
23
# File 'lib/weather_funds/result_set.rb', line 21

def lotteries
  @lotteries ||= extract_winners
end

#resultsObject



17
18
19
# File 'lib/weather_funds/result_set.rb', line 17

def results
  @results ||= extract_results
end