Sha256: a671717fcfa5fbcf832074037ca4777fad79056ab8c6625bd401a51d5fa39df5

Contents?: true

Size: 419 Bytes

Versions: 1

Compression:

Stored size: 419 Bytes

Contents

module Forecastr
  class Wind
    DIRECTIONS = ["N","NNE","NE","ENE","E","ESE", "SE", "SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"]

    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

1 entries across 1 versions & 1 rubygems

Version Path
forecastr-0.1.5 lib/forecastr/wind.rb