Class: PeriodicTable::PeriodicTableApi

Inherits:
Object
  • Object
show all
Defined in:
lib/periodic_table/periodic_table_api.rb

Instance Method Summary collapse

Constructor Details

#initializePeriodicTableApi

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