class AEMO::Market::Interval
@author Joel Courtney @abstract @since 0.1.0
Constants
- INTERVALS
Attributes
Public Class Methods
Create a new instance of an Interval
@param [Time] datetime @param [Hash] options Hash of optional data values @return [AEMO::Market::Interval]
# File lib/aemo/market/interval.rb, line 24 def initialize(datetime, options = {}) @datetime = Time.parse("#{datetime} +1000") @region = options['REGION'] @total_demand = options['TOTALDEMAND'] @rrp = options['RRP'] @period_type = options['PERIODTYPE'] end
Public Instance Methods
All AEMO
Data operates in Australian Eastern Standard Time All AEMO
Data aggregates to the trailing edge of the period (this makes it difficult to do daily aggregations :( ) @param [Boolean] trailing_edge selection of either the trailing edge of the period or the rising edge of the period for the date time @return [Time] a time object of the trailing edge of the interval
# File lib/aemo/market/interval.rb, line 38 def datetime(trailing_edge = true) t = @datetime # If the datetime requested is the trailing edge, offset as per interval requirement unless trailing_edge # This is for dispatch intervals of five minutes if dispatch? t -= 5 * 60 elsif trading? t -= 30 * 60 end end t end
@return [Boolean] returns true if the interval type is dispatch
# File lib/aemo/market/interval.rb, line 63 def dispatch? @period_type.nil? || @period_type.empty? end
@return [Time] the time of the
# File lib/aemo/market/interval.rb, line 53 def interval_length Time.at(300) end
@return [Symbol] :dispatch or :trading
# File lib/aemo/market/interval.rb, line 58 def interval_type dispatch? ? :dispatch : :trading end
@return [Boolean] returns true if the interval type is trading
# File lib/aemo/market/interval.rb, line 68 def trading? !dispatch? end
@return [Float] the value of the interval in Australian Dollars
# File lib/aemo/market/interval.rb, line 73 def value @value ||= Float::NAN @value = (@total_demand * @rrp).round(2) if @total_demand.class == Float && @rrp.class == Float @value end