class Elementy::Element

Attributes

electrons[RW]
group[RW]
molar[RW]
name[RW]
number[RW]
position[RW]
symbol[RW]

Public Class Methods

all() click to toggle source
# File lib/elementy/element.rb, line 8
def all
  @all ||= defaults.map { |d| new d }
end
defaults() click to toggle source
# File lib/elementy/element.rb, line 16
def defaults
  YAML.load(File.open "#{Elementy.root}/data/elements.yaml")
end
each() { |e| ... } click to toggle source
# File lib/elementy/element.rb, line 12
def each
  all.each { |e| yield e }
end
new(attributes) click to toggle source
# File lib/elementy/element.rb, line 29
def initialize(attributes)
  attributes.each do |k,v|
    send "#{k}=", v
  end
end

Public Instance Methods

to_console() click to toggle source
# File lib/elementy/element.rb, line 40
def to_console
  to_hash.map do |k,v|
    "   #{k}:#{' ' * (12-k.length)}#{v}"
  end.join("\n")
end
to_hash() click to toggle source
# File lib/elementy/element.rb, line 35
def to_hash
  { symbol: symbol, name: name, number: number, molar: molar, 
    position: position, group: group, electrons: electrons }
end