Class: Ilm::Chemistry::Element

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_massObject

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_numberObject

Returns the value of attribute atomic_number.



9
10
11
# File 'lib/ilm/chemistry/element.rb', line 9

def atomic_number
  @atomic_number
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/ilm/chemistry/element.rb', line 9

def name
  @name
end

#symbolObject

Returns the value of attribute symbol.



9
10
11
# File 'lib/ilm/chemistry/element.rb', line 9

def symbol
  @symbol
end