class HG::Weather::Speed
Attributes
direction[RW]
km_h[RW]
miles_h[RW]
Public Class Methods
new(speed, direction = nil, format = :km)
click to toggle source
# File lib/hg/weather/speed.rb, line 10 def initialize speed, direction = nil, format = :km return if speed.nil? speed = speed.to_f if format == :km @km_h = speed @miles_h = (speed * 0.621371).round(2) else @miles_h = speed @km_h = (speed * 1.60934).round(2) end end
Public Instance Methods
get_with_format()
click to toggle source
# File lib/hg/weather/speed.rb, line 23 def get_with_format case Weather.speed when :km @km_h when :miles @miles_h end end
inspect()
click to toggle source
# File lib/hg/weather/speed.rb, line 32 def inspect self.to_s end
to_f()
click to toggle source
# File lib/hg/weather/speed.rb, line 40 def to_f self.get_with_format end
to_i()
click to toggle source
# File lib/hg/weather/speed.rb, line 44 def to_i self.get_with_format.to_i end
to_s()
click to toggle source
# File lib/hg/weather/speed.rb, line 36 def to_s "#{self.get_with_format} #{Weather.speed.to_s.downcase}/h" end