Class: AEMO::Market::Node Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/aemo/market/node.rb

Overview

This class is abstract.

AEMO::Market::Interval

Author:

  • Joel Courtney

Since:

  • 0.1.0

Constant Summary collapse

IDENTIFIERS =

Since:

  • 0.1.0

%w[NSW QLD SA TAS VIC].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ Node

Returns a new instance of Node.

Since:

  • 0.1.0



15
16
17
18
19
20
21
22
23
24
# File 'lib/aemo/market/node.rb', line 15

def initialize(identifier)
  unless IDENTIFIERS.include?(identifier.upcase)
    raise ArgumentError,
          "Node Identifier '#{identifier}' is not valid."
  end

  @identifier = identifier
  @current_trading = []
  @current_dispatch = []
end

Instance Attribute Details

#identifierObject

Since:

  • 0.1.0



13
14
15
# File 'lib/aemo/market/node.rb', line 13

def identifier
  @identifier
end

Instance Method Details

#current_dispatchArray<AEMO::Market::Interval>

Return the current dispatch data

Returns:

Since:

  • 0.1.0



29
30
31
32
# File 'lib/aemo/market/node.rb', line 29

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

#current_tradingArray<AEMO::Market::Interval>

Return the current trading data

Returns:

Since:

  • 0.1.0



37
38
39
40
41
42
43
44
# File 'lib/aemo/market/node.rb', line 37

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