Class: Alumina::Element
Overview
Each of the elements has a singleton instance of this class. You do not create instances of this class; they are loaded from a data file.
Instance Attribute Summary collapse
-
#atomic_number ⇒ Fixnum
readonly
The element’s atomic number (hydrogen is 1).
-
#name ⇒ String
readonly
The element’s name.
-
#symbol ⇒ String
readonly
The element’s symbol (hydrogen is @H@).
Instance Method Summary collapse
-
#<=>(other) ⇒ -1, ...
Provides a natural ordering based on atomic number.
-
#initialize(atomic_number, name, symbol) ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize(atomic_number, name, symbol) ⇒ Element
Returns a new instance of Element.
15 16 17 18 19 |
# File 'lib/alumina/element.rb', line 15 def initialize(atomic_number, name, symbol) @atomic_number = atomic_number @name = name @symbol = symbol end |
Instance Attribute Details
#atomic_number ⇒ Fixnum (readonly)
Returns The element’s atomic number (hydrogen is 1).
8 9 10 |
# File 'lib/alumina/element.rb', line 8 def atomic_number @atomic_number end |
#name ⇒ String (readonly)
Returns The element’s name.
10 11 12 |
# File 'lib/alumina/element.rb', line 10 def name @name end |
#symbol ⇒ String (readonly)
Returns The element’s symbol (hydrogen is @H@).
12 13 14 |
# File 'lib/alumina/element.rb', line 12 def symbol @symbol end |
Instance Method Details
#<=>(other) ⇒ -1, ...
Provides a natural ordering based on atomic number.
26 27 28 |
# File 'lib/alumina/element.rb', line 26 def <=>(other) atomic_number <=> other.atomic_number end |