Skip to content

Commit

Permalink
Merge pull request #18 from jufemaiz/feature/AEMONMI#current_annual_load
Browse files Browse the repository at this point in the history
Feature/aemonmi#current annual load
  • Loading branch information
jufemaiz committed Jun 23, 2016
2 parents 6b4f9de + 5542944 commit 33c2dc9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion aemo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
11 changes: 9 additions & 2 deletions lib/aemo/nmi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/aemo/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# @author Joel Courtney <[email protected]>
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)
Expand Down
7 changes: 7 additions & 0 deletions spec/lib/aemo/nmi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 33c2dc9

Please sign in to comment.