class Stormglass::Response
Responses from Stormglass
API are wrapped in this class
Public Class Methods
new(src)
click to toggle source
# File lib/stormglass/response.rb, line 10 def initialize(src) @src = JSON.parse(src) end
Public Instance Methods
find(string)
click to toggle source
takes a string like “7PM EST” and returns the relevant hour if found
# File lib/stormglass/response.rb, line 41 def find(string) hours.find{|h| h.time == Time.parse(string)} end
first()
click to toggle source
# File lib/stormglass/response.rb, line 32 def first hours.first end
hours()
click to toggle source
an array of Stormglass::Hour
instances
# File lib/stormglass/response.rb, line 15 def hours @hours ||= [] return @hours if !@hours.empty? src['hours'].each{|h| @hours << Stormglass::Hour.new(h) } @hours end
inspect()
click to toggle source
# File lib/stormglass/response.rb, line 26 def inspect string = '#<' + "#{self.class.to_s} remaining_requests=#{remaining_requests}, " string +="hours=#{hours.to_s}> " string end
last()
click to toggle source
# File lib/stormglass/response.rb, line 36 def last hours.last end
meta()
click to toggle source
# File lib/stormglass/response.rb, line 45 def meta src['meta'] end
remaining_requests()
click to toggle source
# File lib/stormglass/response.rb, line 49 def remaining_requests meta['dailyQuota'] - meta['requestCount'] end
src()
click to toggle source
# File lib/stormglass/response.rb, line 22 def src @src end