Class: Tide
- Inherits:
-
Object
- Object
- Tide
- Defined in:
- lib/tide.rb
Constant Summary collapse
- POST_URL =
'http://www.waterlevels.gc.ca/cgi-bin/tide-shc.cgi'
- TIDE_REGEX =
/#\sDate;Time;Height<br>(.*)<br><\/p><\/td>/
- STATION_REGEX =
/#\sStation\s:\s(.*)\s\(\d+\).*/
Class Method Summary collapse
-
.station(sid) ⇒ Object
Shortcut for station lookup.
Instance Method Summary collapse
-
#data ⇒ Object
Download raw data.
-
#initialize(options = {}) ⇒ Tide
constructor
Create new tide table.
-
#to_csv ⇒ Object
Returns semi-colon delimited list of tide data.
-
#to_html ⇒ Object
Returns formatted html table of tide data.
Constructor Details
#initialize(options = {}) ⇒ Tide
Create new tide table.
12 13 14 15 16 17 |
# File 'lib/tide.rb', line 12 def initialize( = {}) = { :station => 610, :timezone => 'AST', :date => Time.now }.merge() @station = [:station] @timezone = [:timezone] @date = [:date] end |
Class Method Details
.station(sid) ⇒ Object
Shortcut for station lookup
20 21 22 |
# File 'lib/tide.rb', line 20 def self.station(sid) new(:station => sid) end |
Instance Method Details
#data ⇒ Object
Download raw data
25 26 27 |
# File 'lib/tide.rb', line 25 def data @data ||= download_tide_data end |
#to_csv ⇒ Object
Returns semi-colon delimited list of tide data.
30 31 32 |
# File 'lib/tide.rb', line 30 def to_csv @csv ||= format_csv end |
#to_html ⇒ Object
Returns formatted html table of tide data.
35 36 37 |
# File 'lib/tide.rb', line 35 def to_html @html ||= format_html end |