diff --git a/aemo.gemspec b/aemo.gemspec index f4e2919..3f79a68 100644 --- a/aemo.gemspec +++ b/aemo.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = 'aemo' s.version = AEMO::VERSION s.platform = Gem::Platform::RUBY - s.date = '2016-05-24' + s.date = '2016-06-14' s.summary = 'Gem providing functionality for the Australian Energy Market Operator data' s.description = 'Gem providing functionality for the Australian Energy Market Operator data. Supports NMIs, NEM12, MSATS Web Services and more' s.authors = ['Joel Courtney', 'Stuart Auld'] diff --git a/lib/aemo/nmi.rb b/lib/aemo/nmi.rb index f364814..eb1133e 100644 --- a/lib/aemo/nmi.rb +++ b/lib/aemo/nmi.rb @@ -604,13 +604,20 @@ def data_streams_by_status(status = 'A') @data_streams.select { |x| x.status == status.to_s } end - # The current daily load + # The current daily load in kWh # - # @return [Integer] the current daily load for the meter + # @return [Integer] the current daily load for the meter in kWh def current_daily_load data_streams_by_status.map { |x| x.averaged_daily_load.to_i }.inject(0, :+) end + # The current annual load in MWh + # + # @return [Integer] the current annual load for the meter in MWh + def current_annual_load + (current_daily_load * 365.2425 / 1000).to_i + end + # A function to validate the NMI provided # # @param nmi [String] the nmi to be checked diff --git a/lib/aemo/version.rb b/lib/aemo/version.rb index 085cc6f..16f2445 100644 --- a/lib/aemo/version.rb +++ b/lib/aemo/version.rb @@ -22,7 +22,7 @@ # @author Joel Courtney module AEMO # aemo version - VERSION = '0.1.29'.freeze + VERSION = '0.1.30'.freeze # aemo version split amongst different revisions MAJOR_VERSION, MINOR_VERSION, REVISION = VERSION.split('.').map(&:to_i) diff --git a/spec/lib/aemo/nmi_spec.rb b/spec/lib/aemo/nmi_spec.rb index f3a11e9..15b2778 100644 --- a/spec/lib/aemo/nmi_spec.rb +++ b/spec/lib/aemo/nmi_spec.rb @@ -160,6 +160,13 @@ end end + describe '#current_annual_load' do + it 'should return zero for no data' do + @nmi = AEMO::NMI.new('4001234567') + expect(@nmi.current_daily_load).to eq(0) + end + end + describe '#meters_by_status' do before(:each) do @nmi = AEMO::NMI.new('4001234567')