Sha256: 5448e9eecb66353183ed055a17afd013e67f60b3033384ce76c724738a79903c
Contents?: true
Size: 426 Bytes
Versions: 3
Compression:
Stored size: 426 Bytes
Contents
module Forecastr class Wind DIRECTIONS = ["N","NNE","NE","ENE","E","ESE", "SE", "SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"] attr_reader :speed, :direction def initialize(json) @json = json end def speed "#{@json['wind']['speed']} m/s" end def direction degrees = @json['wind']['deg'] val = ((degrees/22.5) + 0.5).to_i DIRECTIONS[val % 16] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
forecastr-0.1.2 | lib/forecastr/wind.rb |
forecastr-0.1.1 | lib/forecastr/wind.rb |
forecastr-0.1.0 | lib/forecastr/wind.rb |