Class: BMF::Abgabenrechner
- Inherits:
-
Object
- Object
- BMF::Abgabenrechner
- Defined in:
- lib/abgabenrechner.rb
Instance Attribute Summary collapse
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
- #ausgaben ⇒ Object
-
#initialize(values) ⇒ Abgabenrechner
constructor
A new instance of Abgabenrechner.
Constructor Details
#initialize(values) ⇒ Abgabenrechner
Returns a new instance of Abgabenrechner.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/abgabenrechner.rb', line 12 def initialize(values) time = Time.new if time.year == 2011 if time.month == 11 @year = "2011bisNov" else @year = "2011Dez" end else @year = Time.new.year end url_params = [] values.keys.each do | value | if value.to_s == "year" @year = values[value] else url_params << "&#{value.to_s.upcase}=#{values[value]}" end end @url_path = "/interface/#{@year}.jsp?#{url_params.join}" EventMachine.run { = { :connect_timeout => 5, # default connection setup timeout :inactivity_timeout => 10, # default connection inactivity (post-setup) timeout :ssl => { :private_key_file => '/tmp/server.key', :cert_chain_file => '/tmp/server.crt', :verify_peer => false }, :proxy => { :port => 443, # proxy port } } http = EventMachine::HttpRequest.new("https://www.abgabenrechner.de#{@url_path}").get http.errback { p 'Uh oh'; EM.stop } http.callback { @xml = http.response EventMachine.stop } } end |
Instance Attribute Details
#xml ⇒ Object
Returns the value of attribute xml.
9 10 11 |
# File 'lib/abgabenrechner.rb', line 9 def xml @xml end |
Instance Method Details
#ausgaben ⇒ Object
74 75 76 77 78 79 |
# File 'lib/abgabenrechner.rb', line 74 def ausgaben parser = XML::SaxParser.string(@xml) parser.callbacks = Saxparser.new parser.parse return parser.callbacks.ausgaben end |