Sha256: c841c9409e8185b46dfcda58fed7a11dd21b5d24879fc7a12618065e97b5a401

Contents?: true

Size: 940 Bytes

Versions: 12

Compression:

Stored size: 940 Bytes

Contents

module GreenButtonData
  class UsageSummary < Entry
    include Enumerations
    include Utilities

    attr_reader :billing_period,
                :overall_consumption_last_period,
                :tariff,
                :cost_additional_detail_last_periods

    attr_writer :commodity,
                :quality_of_reading

    def commodity
      if @commodity.is_a? Numeric
        COMMODITY[@commodity]
      elsif @commodity.is_a? Symbol
        @commodity
      end
    end

    def quality_of_reading
      if @quality_of_reading.is_a? Numeric
        QUALITY_OF_READING[@quality_of_reading]
      elsif @quality_of_reading.is_a? Symbol
        @quality_of_reading
      end
    end

    def status_timestamp(kwargs = {})
      epoch_to_time @status_time_stamp, kwargs
    end

    def to_s
      "#{@billing_period}: #{@overall_consumption_last_period}"
    end

    def cost
      @bill_last_period / 100_000.0
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
green-button-data-2.0.1 lib/green-button-data/usage_summary.rb
green-button-data-2.0.0 lib/green-button-data/usage_summary.rb
green-button-data-1.0.3 lib/green-button-data/usage_summary.rb
green-button-data-1.0.1 lib/green-button-data/usage_summary.rb
green-button-data-1.0.0 lib/green-button-data/usage_summary.rb
green-button-data-0.7.5 lib/green-button-data/usage_summary.rb
green-button-data-0.7.4 lib/green-button-data/usage_summary.rb
green-button-data-0.7.3 lib/green-button-data/usage_summary.rb
green-button-data-0.7.2 lib/green-button-data/usage_summary.rb
green-button-data-0.7.1 lib/green-button-data/usage_summary.rb
green-button-data-0.7.0 lib/green-button-data/usage_summary.rb
green-button-data-0.6.0 lib/green-button-data/usage_summary.rb