Sha256: cdca3a438c92316bec5d46248adb2c3a1cd0bee2a301e7f115de9de9f8e544f5

Contents?: true

Size: 1.52 KB

Versions: 19

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

module AEMO
  # AEMO::Register represents a register on a meter
  class Register
    attr_accessor :controlled_load, :dial_format, :multiplier,
                  :network_tariff_code, :register_id, :status, :time_of_day,
                  :unit_of_measure

    # Initialize a register
    #
    # @param [Hash] opts = {} the parameters to set
    # @return [AEMO::Register] an instance of an AEMO::Register
    def initialize(opts = {})
      @controlled_load     = opts[:controlled_load]
      @dial_format         = opts[:dial_format]
      @multiplier          = opts[:multiplier]
      @network_tariff_code = opts[:network_tariff_code]
      @register_id         = opts[:register_id]
      @status              = opts[:status]
      @time_of_day         = opts[:time_of_day]
      @unit_of_measure     = opts[:unit_of_measure]
    end

    # Initialize a new register from an MSATS hash
    #
    # @param [Hash] register the MSATS hash
    # @return [AEMO::Register] description of returned object
    def self.from_hash(register)
      AEMO::Register.new(
        controlled_load:     register['ControlledLoad'] == 'Y',
        dial_format:         register['DialFormat'],
        multiplier:          register['Multiplier'],
        network_tariff_code: register['NetworkTariffCode'],
        register_id:         register['RegisterID'],
        status:              register['Status'],
        time_of_day:         register['TimeOfDay'],
        unit_of_measure:     register['UnitOfMeasure']
      )
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
aemo-0.5.1 lib/aemo/register.rb
aemo-0.5.0 lib/aemo/register.rb
aemo-0.4.1 lib/aemo/register.rb
aemo-0.4.0 lib/aemo/register.rb
aemo-0.3.6 lib/aemo/register.rb
aemo-0.3.5 lib/aemo/register.rb
aemo-0.3.4 lib/aemo/register.rb
aemo-0.3.3 lib/aemo/register.rb
aemo-0.3.2 lib/aemo/register.rb
aemo-0.3.1 lib/aemo/register.rb
aemo-0.3.0 lib/aemo/register.rb
aemo-0.3.0.pre.rc1 lib/aemo/register.rb
aemo-0.2.1 lib/aemo/register.rb
aemo-0.2.0 lib/aemo/register.rb
aemo-0.1.45 lib/aemo/register.rb
aemo-0.1.44 lib/aemo/register.rb
aemo-0.1.42 lib/aemo/register.rb
aemo-0.1.41 lib/aemo/register.rb
aemo-0.1.40 lib/aemo/register.rb