Class: PeriodicTable::PeriodicTableApi::ApiResponse

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

Overview

Wow, this is ugly. I did not expect nested XML.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ ApiResponse

Returns a new instance of ApiResponse.



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/periodic_table/periodic_table_api.rb', line 33

def initialize(result)
  xml = Nokogiri::XML.parse(result)
  @atomic_weight = xml.at('AtomicWeight').text
  @symbol = xml.at('Symbol').text
  @atomic_number = xml.at('AtomicNumber').text
  @element_name = xml.at('ElementName').text
  @boiling_point = xml.at('BoilingPoint').text
  @ionisation_potential = xml.at('IonisationPotential').text
  @electro_negativity = xml.at('EletroNegativity').text
  @atomic_radius = xml.at('AtomicRadius').text
  @melting_point = xml.at('MeltingPoint').text
  @density = xml.at('Density').text
end

Instance Attribute Details

#atomic_numberObject (readonly)

Returns the value of attribute atomic_number.



22
23
24
# File 'lib/periodic_table/periodic_table_api.rb', line 22

def atomic_number
  @atomic_number
end

#atomic_radiusObject (readonly)

Returns the value of attribute atomic_radius.



22
23
24
# File 'lib/periodic_table/periodic_table_api.rb', line 22

def atomic_radius
  @atomic_radius
end

#atomic_weightObject (readonly)

Returns the value of attribute atomic_weight.



22
23
24
# File 'lib/periodic_table/periodic_table_api.rb', line 22

def atomic_weight
  @atomic_weight
end

#boiling_pointObject (readonly)

Returns the value of attribute boiling_point.



22
23
24
# File 'lib/periodic_table/periodic_table_api.rb', line 22

def boiling_point
  @boiling_point
end

#densityObject (readonly)

Returns the value of attribute density.



22
23
24
# File 'lib/periodic_table/periodic_table_api.rb', line 22

def density
  @density
end

#electro_negativityObject (readonly)

Returns the value of attribute electro_negativity.



22
23
24
# File 'lib/periodic_table/periodic_table_api.rb', line 22

def electro_negativity
  @electro_negativity
end

#element_nameObject (readonly)

Returns the value of attribute element_name.



22
23
24
# File 'lib/periodic_table/periodic_table_api.rb', line 22

def element_name
  @element_name
end

#ionisation_potentialObject (readonly)

Returns the value of attribute ionisation_potential.



22
23
24
# File 'lib/periodic_table/periodic_table_api.rb', line 22

def ionisation_potential
  @ionisation_potential
end

#melting_pointObject (readonly)

Returns the value of attribute melting_point.



22
23
24
# File 'lib/periodic_table/periodic_table_api.rb', line 22

def melting_point
  @melting_point
end

#symbolObject (readonly)

Returns the value of attribute symbol.



22
23
24
# File 'lib/periodic_table/periodic_table_api.rb', line 22

def symbol
  @symbol
end