class Tankerkoenig::Price
Attributes
diesel[R]
e10[R]
e5[R]
station_id[R]
status[R]
Public Class Methods
conn()
click to toggle source
# File lib/tankerkoenig/price.rb, line 44 def self.conn Tankerkoenig.conn end
get(ids)
click to toggle source
# File lib/tankerkoenig/price.rb, line 26 def self.get(ids) ids = ids.join(',') if ids.is_a?(Array) return Response.new(message: 'ids must be an Array or a String') unless ids.is_a?(String) response = conn.get('prices.php', ids: ids) attributes = JSON.parse(response.body, symbolize_names: true) response = Response.new(attributes) response.result = [] if response.success? attributes[:prices].to_a.each do |p| response.result << new(p.first, p.last) end end response end
new(*attributes)
click to toggle source
# File lib/tankerkoenig/price.rb, line 8 def initialize(*attributes) if attributes.count == 2 @station_id = attributes[0] @status = attributes[1][:status] @e5 = attributes[1][:e5] @e10 = attributes[1][:e10] @diesel = attributes[1][:diesel] end if attributes.count == 5 @station_id = attributes[0] @e5 = attributes[1] @e10 = attributes[2] @diesel = attributes[3] @status = attributes[4] ? 'open' : 'closed' end end
Public Instance Methods
closed?()
click to toggle source
# File lib/tankerkoenig/price.rb, line 56 def closed? @status == 'closed' end
diesel?()
click to toggle source
# File lib/tankerkoenig/price.rb, line 72 def diesel? @diesel != false end
e10?()
click to toggle source
# File lib/tankerkoenig/price.rb, line 68 def e10? @e10 != false end
e5?()
click to toggle source
# File lib/tankerkoenig/price.rb, line 64 def e5? @e5 != false end
open?()
click to toggle source
# File lib/tankerkoenig/price.rb, line 52 def open? @status == 'open' end
prices?()
click to toggle source
# File lib/tankerkoenig/price.rb, line 60 def prices? @status != 'no prices' && !@e5.nil? && !@e10.nil? && !@diesel.nil? end
station()
click to toggle source
# File lib/tankerkoenig/price.rb, line 48 def station Station.detail(@station_id).result end