class Alchy::Element

Attributes

name[RW]

Public Class Methods

new(name) click to toggle source
# File lib/alchy/element.rb, line 5
def initialize(name)
  self.name = name
end

Public Instance Methods

offsprings() click to toggle source
# File lib/alchy/element.rb, line 9
def offsprings
  read { |combis| puts "with #{combis[0]} => #{combis[1]}"}
  return
end
origin() click to toggle source
# File lib/alchy/element.rb, line 14
def origin
  search_for { |parents| puts "from #{parents[0]} and #{parents[1]}" }
  return
end

Private Instance Methods

read() { |father, child| ... } click to toggle source
# File lib/alchy/element.rb, line 20
def read
  Alchy::ELEMENTS.each do |mother, combi|
    if mother == self.name
      combi.each do |father, child|
        yield [father, child]
      end
    else
      combi.each do |father, child|
        yield [mother, child] if father == self.name
      end
    end
  end
end
search_for() { |mother, father| ... } click to toggle source
# File lib/alchy/element.rb, line 34
def search_for(&block)
  Alchy::ELEMENTS.each do |mother, combi|
    combi.each do |father, child|
      yield [mother, father] if child == self.name
    end
  end
end