Class: Meteorology::Temperature

Inherits:
Object
  • Object
show all
Defined in:
lib/meteorology/temperature.rb

Instance Method Summary collapse

Constructor Details

#initialize(system, degrees) ⇒ Temperature

Returns a new instance of Temperature.

Raises:

  • (ArgumentError)


3
4
5
6
7
8
# File 'lib/meteorology/temperature.rb', line 3

def initialize(system, degrees)
  raise ArgumentError.new("Need :farenheit or :celcius") unless [:farenheit, :celcius].include? system
  
  @degrees = degrees
  @system = system
end

Instance Method Details

#to_sObject



10
11
12
# File 'lib/meteorology/temperature.rb', line 10

def to_s
  "#{@degrees} #{@system.to_s[0,1].upcase}"
end