Class: SingleDayWeather

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(month, dieroller, precipitation_occurance_chart = PrecipitationOccurance.new({ 0..100 => NullPrecipitationInfo.new() }), record_temp = nil, terrain = :plains, latitude = 40) ⇒ SingleDayWeather

Returns a new instance of SingleDayWeather.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/singledayweather.rb', line 13

def initialize (month, dieroller, 
                precipitation_occurance_chart=PrecipitationOccurance.new({ 0..100 => NullPrecipitationInfo.new() }),
                record_temp=nil,
                terrain = :plains,
                latitude = 40)
  @temperature_range = adjust_for_latitude(month.temp_range(dieroller, record_temp), latitude)
  @sky_conditions = month.sky_conditions(dieroller)
  @record_temp = record_temp
  @precipitation =
    precipitation_occurance_chart.type(month.has_precipitation(dieroller) ? dieroller : NullDieRoller.new(),
                                       @temperature_range, terrain)
  @wind = Wind.new(dieroller)
end

Instance Attribute Details

#precipitationObject (readonly)

Returns the value of attribute precipitation.



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

def precipitation
  @precipitation
end

#sky_conditionsObject (readonly)

Returns the value of attribute sky_conditions.



9
10
11
# File 'lib/singledayweather.rb', line 9

def sky_conditions
  @sky_conditions
end

#temperature_rangeObject (readonly)

Returns the value of attribute temperature_range.



8
9
10
# File 'lib/singledayweather.rb', line 8

def temperature_range
  @temperature_range
end

#windObject (readonly)

Returns the value of attribute wind.



11
12
13
# File 'lib/singledayweather.rb', line 11

def wind
  @wind
end

Instance Method Details

#inspectObject



27
28
29
# File 'lib/singledayweather.rb', line 27

def inspect
  "#{@record_temp} #{@temperature_range} #{@sky_conditions} #{@precipitation} #{@wind}"
end