Class: AEMO::Region Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/aemo/region.rb,
lib/aemo/dispatchable.rb

Overview

This class is abstract.

AEMO::Region

Author:

  • Joel Courtney

Since:

  • 0.1.0

Constant Summary collapse

REGIONS =

Regions under juristiction

Since:

  • 0.1.0

{
  'ACT' => 'Australian Capital Territory',
  'NSW' => 'New South Wales',
  'QLD' => 'Queensland',
  'SA'  => 'South Australia',
  'TAS' => 'Tasmania',
  'VIC' => 'Victoria',
  'NT'  => 'Northern Territory',
  'WA'  => 'Western Australia'
}.freeze
DISPATCH_TYPE =

Since:

  • 0.1.0

['Generator', 'Load Norm Off', 'Network Service Provider'].freeze
CATEGORY =

Since:

  • 0.1.0

['Market', 'Non-Market'].freeze
CLASSIFICATION =

Since:

  • 0.1.0

['Scheduled', 'Semi-Scheduled', 'Non-Scheduled'].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(region) ⇒ Region

Returns a new instance of Region.

Raises:

  • (ArgumentError)

Since:

  • 0.1.0



22
23
24
25
26
27
# File 'lib/aemo/region.rb', line 22

def initialize(region)
  raise ArgumentError, "Region '#{region}' is not valid." unless valid_region?(region)
  @region = region
  @current_trading = []
  @current_dispatch = []
end

Instance Attribute Details

#regionObject

Since:

  • 0.1.0



20
21
22
# File 'lib/aemo/region.rb', line 20

def region
  @region
end

Class Method Details

.allObject

Since:

  • 0.1.0



55
56
57
# File 'lib/aemo/region.rb', line 55

def self.all
  REGIONS.keys.map { |k| AEMO::Region.new(k) }
end

Instance Method Details

#abbrObject

Since:

  • 0.1.0



29
30
31
# File 'lib/aemo/region.rb', line 29

def abbr
  @region
end

#current_dispatchObject

Since:

  • 0.1.0



41
42
43
44
45
46
# File 'lib/aemo/region.rb', line 41

def current_dispatch
  if @current_dispatch.empty? || @current_dispatch.last.datetime != (Time.now - Time.now.to_i % 300)
    @current_dispatch = AEMO::Market.current_dispatch(@region)
  end
  @current_dispatch
end

#current_tradingObject

Since:

  • 0.1.0



48
49
50
51
52
53
# File 'lib/aemo/region.rb', line 48

def current_trading
  if @current_trading.empty? || @current_trading.reject { |i| i.period_type != 'TRADE' }.last.datetime != (Time.now - Time.now.to_i % 300)
    @current_trading = AEMO::Market.current_trading(@region)
  end
  @current_trading
end

#fullnameObject

Since:

  • 0.1.0



37
38
39
# File 'lib/aemo/region.rb', line 37

def fullname
  REGIONS[@region]
end

#to_sObject

Since:

  • 0.1.0



33
34
35
# File 'lib/aemo/region.rb', line 33

def to_s
  @region
end