class Hash

Public Instance Methods

choose() click to toggle source

{:a => 1, :b => 2, …}

# File lib/fortune.rb, line 60
def choose
  Fortune::Event.select(self)
end
choose_set() click to toggle source

{[:a, :b] => 1, [:c] => 2, …} ||

{10 => 1, 15 => 2, ...}
# File lib/fortune.rb, line 66
def choose_set
  Fortune::P.n_select(self)
end
to_P() click to toggle source
# File lib/fortune.rb, line 47
def to_P
  n = 0
  self.each{|k,v| n += v.to_i}
  self.each{|k,v| self[k] = Fortune::P(:m => v.to_i, :n => n)}
  self
end
to_p() click to toggle source
# File lib/fortune.rb, line 54
def to_p
  self.to_P.each{|k,v| self[k] = v.value}
  self
end