class AEMO::Market::Node

AEMO::Market::Interval

@author Joel Courtney @abstract @since 0.1.0

Constants

IDENTIFIERS

Attributes

identifier[RW]

Public Class Methods

new(identifier) click to toggle source
# 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

Public Instance Methods

current_dispatch() click to toggle source

Return the current dispatch data

@return [Array<AEMO::Market::Interval>]

# 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_trading() click to toggle source

Return the current trading data

@return [Array<AEMO::Market::Interval>]

# 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