Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/lifematon.rb

Instance Method Summary collapse

Instance Method Details

#by_life(lifestring) ⇒ Object



33
34
35
36
37
# 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) ⇒ Object



10
11
12
# File 'lib/lifematon.rb', line 10

def life(str)
  str.set_life_hash! @lifes
end

#mean(str) ⇒ Object



21
22
23
# File 'lib/lifematon.rb', line 21

def mean(str)
  @lifes[str]
end

#state!(mean) ⇒ Object



4
5
6
7
8
# File 'lib/lifematon.rb', line 4

def state!(mean)
  @lifes = {}
  @lifes = {"#{self}" => mean}
  return self
end

#state_merge(lifestrings) ⇒ Object



14
15
16
17
18
19
# 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_lifeObject



29
30
31
# File 'lib/lifematon.rb', line 29

def to_life
  by_life(self)
end

#to_life_hashObject



25
26
27
# File 'lib/lifematon.rb', line 25

def to_life_hash
  @lifes
end