Class: Ilm::Chemistry::Element
- Inherits:
-
Object
- Object
- Ilm::Chemistry::Element
- Defined in:
- lib/ilm/chemistry/element.rb
Overview
This class has functionality for elements Ex: symbol, atomic mass, atomic number
Constant Summary collapse
- ATTRS =
%w[symbol name atomic_number atomic_mass].freeze
- ELEMENTS =
Data taken from ‘www.science.co.il/elements/’
[]
Instance Attribute Summary collapse
-
#atomic_mass ⇒ Object
Returns the value of attribute atomic_mass.
-
#atomic_number ⇒ Object
Returns the value of attribute atomic_number.
-
#name ⇒ Object
Returns the value of attribute name.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
Instance Method Summary collapse
-
#initialize(arg) ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize(arg) ⇒ Element
Returns a new instance of Element.
15 16 17 18 19 20 |
# File 'lib/ilm/chemistry/element.rb', line 15 def initialize(arg) @name = arg[1] @symbol = arg[0] @atomic_number = arg[2].to_i @atomic_mass = Unitwise(arg[3].to_f, 'u') end |
Instance Attribute Details
#atomic_mass ⇒ Object
Returns the value of attribute atomic_mass.
9 10 11 |
# File 'lib/ilm/chemistry/element.rb', line 9 def atomic_mass @atomic_mass end |
#atomic_number ⇒ Object
Returns the value of attribute atomic_number.
9 10 11 |
# File 'lib/ilm/chemistry/element.rb', line 9 def atomic_number @atomic_number end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/ilm/chemistry/element.rb', line 9 def name @name end |
#symbol ⇒ Object
Returns the value of attribute symbol.
9 10 11 |
# File 'lib/ilm/chemistry/element.rb', line 9 def symbol @symbol end |