Sha256: 3900ffef37bbbfa3415a14dc16b35b6f27c36c6941cb433e0ea65027c113dfe8
Contents?: true
Size: 455 Bytes
Versions: 2
Compression:
Stored size: 455 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(speed, angle) @speed = speed @angle = angle end def speed "#{@speed} m/s" end def direction val = ((@angle/22.5) + 0.5).to_i DIRECTIONS[val % 16] end def to_s "#{speed} #{direction}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
forecastr-0.1.4 | lib/forecastr/wind.rb |
forecastr-0.1.3 | lib/forecastr/wind.rb |