Class: ANP
- Inherits:
-
Object
- Object
- ANP
- Defined in:
- lib/anp_prices.rb
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#fuel ⇒ Object
readonly
Returns the value of attribute fuel.
Instance Method Summary collapse
-
#initialize(city = nil, fuel = nil) ⇒ ANP
constructor
A new instance of ANP.
- #prices ⇒ Object
Constructor Details
#initialize(city = nil, fuel = nil) ⇒ ANP
Returns a new instance of ANP.
7 8 9 10 11 12 13 14 |
# File 'lib/anp_prices.rb', line 7 def initialize(city = nil, fuel = nil) raise ArgumentError if city.nil? or fuel.nil? RestClient.proxy = ENV["http_proxy"] @city = find_code_of(city) @fuel = fuel end |
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city.
5 6 7 |
# File 'lib/anp_prices.rb', line 5 def city @city end |
#fuel ⇒ Object (readonly)
Returns the value of attribute fuel.
5 6 7 |
# File 'lib/anp_prices.rb', line 5 def fuel @fuel end |
Instance Method Details
#prices ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/anp_prices.rb', line 16 def prices lines = [] request_page.each do |node| node.inner_html.each_line.with_index do |line, index| next if index < 34 line.encode! "ISO-8859-1", "UTF-8", :invalid => :replace, :replace => "?" line.gsub! /<(.*?)>/, "" lines << line.strip end end push_values_with lines end |