Sha256: 41b567c5c2fc10ce237f5a11386d33eba2423ae9690862a57650715190f76f61

Contents?: true

Size: 1.51 KB

Versions: 10

Compression:

Stored size: 1.51 KB

Contents

require 'date'
module Barometer
  #
  # Forecast Measurement
  # a data class for forecasted weather conditions
  #
  # This is basically a data holding class for the forecasted weather
  # conditions.
  #
  class ForecastMeasurement
    
    attr_reader :date, :icon, :condition
    attr_reader :low, :high, :pop, :sun
    
    def date=(date)
      raise ArgumentError unless date.is_a?(Date)
      @date = date
    end
    
    def icon=(icon)
      raise ArgumentError unless icon.is_a?(String)
      @icon = icon
    end
    
    def condition=(condition)
      raise ArgumentError unless condition.is_a?(String)
      @condition = condition
    end
    
    def high=(high)
      raise ArgumentError unless high.is_a?(Barometer::Temperature)
      @high = high
    end
    
    def low=(low)
      raise ArgumentError unless low.is_a?(Barometer::Temperature)
      @low = low
    end
    
    def pop=(pop)
      raise ArgumentError unless pop.is_a?(Fixnum)
      @pop = pop
    end
    
    def sun=(sun)
      raise ArgumentError unless sun.is_a?(Barometer::Sun)
      @sun = sun
    end
    
    #
    # helpers
    #
    
    # creates "?" helpers for all attributes (which maps to nil?)
    def method_missing(method,*args)
      # if the method ends in ?, then strip it off and see if we
      # respond to the method without the ?
      if (call_method = method.to_s.chomp!("?")) && respond_to?(call_method)
        return send(call_method).nil? ? false : true
      else
        super(method,*args)
      end
    end
    
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
attack-barometer-0.1.0 lib/barometer/data/forecast.rb
attack-barometer-0.2.3 lib/barometer/data/forecast.rb
attack-barometer-0.3.1 lib/barometer/data/forecast.rb
attack-barometer-0.3.2 lib/barometer/data/forecast.rb
barometer-0.1.0 lib/barometer/data/forecast.rb
barometer-0.3.2 lib/barometer/data/forecast.rb
barometer-0.3.1 lib/barometer/data/forecast.rb
barometer-0.2.2 lib/barometer/data/forecast.rb
barometer-0.2.3 lib/barometer/data/forecast.rb
barometer-0.2.1 lib/barometer/data/forecast.rb