Class: PeriodicTable::PeriodicTableApi
- Inherits:
-
Object
- Object
- PeriodicTable::PeriodicTableApi
- Defined in:
- lib/periodic_table/periodic_table_api.rb
Defined Under Namespace
Classes: ApiResponse
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 |
# File 'lib/periodic_table/periodic_table_api.rb', line 6 def initialize #@client = Savon.client("http://www.webservicex.net/periodictable.asmx?WSDL") @client = Savon.client(wsdl: "http://www.webservicex.net/periodictable.asmx?WSDL") end |
Instance Method Details
#query(element_name) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/periodic_table/periodic_table_api.rb', line 11 def query(element_name) api_response = @client.call(:get_atomic_number, message: { 'ElementName' => element_name }) result = api_response.to_hash[:get_atomic_number_response][:get_atomic_number_result] #puts "===========RESULT=============" #puts result ApiResponse.new(result) end |