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.

Raises:

  • (ArgumentError)

Since:

  • 0.1.0



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

def initialize(identifier)
  raise ArgumentError, "Node Identifier '#{identifier}' is not valid." unless IDENTIFIERS.include?(identifier.upcase)
  @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



25
26
27
28
# File 'lib/aemo/market/node.rb', line 25

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



33
34
35
36
37
38
# File 'lib/aemo/market/node.rb', line 33

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