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 |
# File 'lib/abgabenrechner.rb', line 12 def initialize(values) @year = Time.new.year 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
62 63 64 65 66 67 |
# File 'lib/abgabenrechner.rb', line 62 def ausgaben parser = XML::SaxParser.string(@xml) parser.callbacks = Saxparser.new parser.parse return parser.callbacks.ausgaben end |