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 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
#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
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_trading ⇒ Array<AEMO::Market::Interval>
Return the current trading data
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 |