class String

Public Instance Methods

by_life(lifestring) click to toggle source
# File lib/lifematon.rb, line 33
def by_life(lifestring)
  life_hash = lifestring.to_life_hash
  return "" if life_hash.nil?
  self.split("").map { |x| life_hash[x] }
end
life(str) click to toggle source
# File lib/lifematon.rb, line 10
def life(str)
  str.set_life_hash! @lifes
end
mean(str) click to toggle source
# File lib/lifematon.rb, line 21
def mean(str)
  @lifes[str]
end
state!(mean) click to toggle source
# File lib/lifematon.rb, line 4
def state!(mean)
  @lifes = {}
  @lifes = {"#{self}" => mean}
  return self
end
state_merge(lifestrings) click to toggle source
# File lib/lifematon.rb, line 14
def state_merge(lifestrings)
  lifestrings.each do |lifestring|
    @lifes.merge! lifestring.to_life_hash
  end
  (@lifes.keys.join).set_life_hash! @lifes
end
to_life() click to toggle source
# File lib/lifematon.rb, line 29
def to_life
  by_life(self)
end
to_life_hash() click to toggle source
# File lib/lifematon.rb, line 25
def to_life_hash
  @lifes
end

Protected Instance Methods

set_life_hash!(life_hash) click to toggle source
# File lib/lifematon.rb, line 40
def set_life_hash!(life_hash)
  @lifes = life_hash
  self
end