Sha256: f0389d02ee5e7392087058922968066a2564014b9970a4a801018b7b0090dfc1
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
module AEMO # AEMO::Market # # @author Joel Courtney # @abstract # @since 0.1.0 module Market include HTTParty base_uri 'www.nemweb.com.au' # Class Methods class << self def current_dispatch(region) response = get "/mms.GRAPHS/GRAPHS/GRAPH_5#{region}1.csv" values = parse_response(response) values end def current_trading(region) response = get "/mms.GRAPHS/GRAPHS/GRAPH_30#{region}1.csv" values = parse_response(response) values end protected def parse_response(response) values = [] if response.response.code == '200' CSV.parse(response.body, headers: true, converters: :numeric) do |row| if row.respond_to?(:to_h) row = row.to_h elsif row.respond_to?(:to_hash) row = row.to_hash else raise NoMethodError, "cannot convert #{row.class} to Hash" end values.push ::AEMO::Market::Interval.new(row['SETTLEMENTDATE'], row) end end values end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aemo-0.1.30 | lib/aemo/market.rb |
aemo-0.1.29 | lib/aemo/market.rb |
aemo-0.1.28 | lib/aemo/market.rb |