Class: AEMO::Market::Node Abstract
- Inherits:
-
Object
- Object
- AEMO::Market::Node
- Defined in:
- lib/aemo/market/node.rb
Overview
This class is abstract.
AEMO::Market::Interval
Constant Summary collapse
- IDENTIFIERS =
%w[NSW QLD SA TAS VIC].freeze
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#current_dispatch ⇒ Array<AEMO::Market::Interval>
Return the current dispatch data.
-
#current_trading ⇒ Array<AEMO::Market::Interval>
Return the current trading data.
-
#initialize(identifier) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(identifier) ⇒ Node
Returns a new instance of Node.
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
#identifier ⇒ Object
13 14 15 |
# File 'lib/aemo/market/node.rb', line 13 def identifier @identifier end |
Instance Method Details
#current_dispatch ⇒ Array<AEMO::Market::Interval>
Return the current dispatch data
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_trading ⇒ Array<AEMO::Market::Interval>
Return the current trading data
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 |