Sha256: 8770ed046692be4788e5bc97f4657b5db3befe4c7bf8f8c12dade53a55aa54f3
Contents?: true
Size: 1.24 KB
Versions: 7
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module AEMO module Market # AEMO::Market::Interval # # @author Joel Courtney # @abstract # @since 0.1.0 class Node IDENTIFIERS = %w[NSW QLD SA TAS VIC].freeze attr_accessor :identifier def initialize(identifier) raise ArgumentError, "Node Identifier '#{identifier}' is not valid." unless IDENTIFIERS.include?(identifier.upcase) @identifier = identifier @current_trading = [] @current_dispatch = [] end # Return the current dispatch data # # @return [Array<AEMO::Market::Interval>] def current_dispatch if @current_dispatch.empty? || @current_dispatch.last.datetime != (Time.now - Time.now.to_i % 300) @current_dispatch = AEMO::Market.current_dispatch(@identifier) end @current_dispatch end # Return the current trading data # # @return [Array<AEMO::Market::Interval>] 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 end end end
Version data entries
7 entries across 7 versions & 1 rubygems