Class: PeriodicTable::PeriodicTableApi
- Inherits:
-
Object
- Object
- PeriodicTable::PeriodicTableApi
- Defined in:
- lib/periodic_table/periodic_table_api.rb
Instance Method Summary collapse
-
#initialize ⇒ PeriodicTableApi
constructor
A new instance of PeriodicTableApi.
- #query(element_name) ⇒ Object
Constructor Details
#initialize ⇒ PeriodicTableApi
Returns a new instance of PeriodicTableApi.
6 7 8 9 10 11 12 |
# File 'lib/periodic_table/periodic_table_api.rb', line 6 def initialize Savon.config.log = false HTTPI.log = false @client = Savon::Client.new do wsdl.document = "http://www.webservicex.net/periodictable.asmx?WSDL" end end |
Instance Method Details
#query(element_name) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/periodic_table/periodic_table_api.rb', line 14 def query(element_name) api_response = @client.request :get_atomic_number do soap.body = {'ElementName' => element_name} end result = api_response.to_hash[:get_atomic_number_response][:get_atomic_number_result] ApiResponse.new(result) end |