Class: Wapi::Report

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

Constant Summary collapse

WAVES_URL =
'http://waves.terra.com.br/surf/ondas'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(beach, url = WAVES_URL) ⇒ Report

Returns a new instance of Report.



13
14
15
16
# File 'lib/wapi.rb', line 13

def initialize(beach, url=WAVES_URL)
  beach_url = "#{url}#{beach}"
  @html = Nokogiri::HTML(open(beach_url))
end

Instance Attribute Details

#htmlObject (readonly)

Returns the value of attribute html.



9
10
11
# File 'lib/wapi.rb', line 9

def html
  @html
end

Instance Method Details

#checkObject



18
19
20
21
22
23
24
25
26
# File 'lib/wapi.rb', line 18

def check
  conditions = {}

  ConditionParser::constants.each do |constant|
    conditions[constant.downcase] = ConditionParser.const_get(constant).extract(@html)
  end

  conditions
end