Class: PeriodicTable::PeriodicTableApi::ApiResponse
- Inherits:
-
Object
- Object
- PeriodicTable::PeriodicTableApi::ApiResponse
- Defined in:
- lib/periodic_table/periodic_table_api.rb
Overview
Wow, this is ugly. I did not expect nested XML.
Instance Attribute Summary collapse
-
#atomic_number ⇒ Object
readonly
Returns the value of attribute atomic_number.
-
#atomic_radius ⇒ Object
readonly
Returns the value of attribute atomic_radius.
-
#atomic_weight ⇒ Object
readonly
Returns the value of attribute atomic_weight.
-
#boiling_point ⇒ Object
readonly
Returns the value of attribute boiling_point.
-
#density ⇒ Object
readonly
Returns the value of attribute density.
-
#electro_negativity ⇒ Object
readonly
Returns the value of attribute electro_negativity.
-
#element_name ⇒ Object
readonly
Returns the value of attribute element_name.
-
#ionisation_potential ⇒ Object
readonly
Returns the value of attribute ionisation_potential.
-
#melting_point ⇒ Object
readonly
Returns the value of attribute melting_point.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
-
#initialize(result) ⇒ ApiResponse
constructor
A new instance of ApiResponse.
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_number ⇒ Object (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_radius ⇒ Object (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_weight ⇒ Object (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_point ⇒ Object (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 |
#density ⇒ Object (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_negativity ⇒ Object (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_name ⇒ Object (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_potential ⇒ Object (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_point ⇒ Object (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 |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
22 23 24 |
# File 'lib/periodic_table/periodic_table_api.rb', line 22 def symbol @symbol end |