Class: Iching

Inherits:
Object
  • Object
show all
Includes:
Dictionaries
Defined in:
lib/iching.rb

Instance Method Summary collapse

Methods included from Dictionaries

#binhex1_key, #binhex2_key, #hex, #hexagram1_key, #hexagram2_key, #list

Instance Method Details

#displayObject



14
15
16
17
18
19
20
# File 'lib/iching.rb', line 14

def display
  if Random.new.rand(1..20) > 1 
    puts hex_symbol, hex_name, hex_symbol(2), hex_name(2)
  else
    puts "A suffusion of yellow."
  end
end

#hex_name(second = false) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/iching.rb', line 22

def hex_name(second = false)
  unless second
    bin_hex = hex.inject('') {|store,stick| store << binhex1_key[stick]}
  else
    bin_hex = hex.inject('') {|store,stick| store << binhex1_key[stick]}
  end
  bin_hex.reverse!
  return list[bin_hex]
end

#hex_symbol(second = false) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/iching.rb', line 32

def hex_symbol(second = false)
  unless second
    hex.inject('') {|store, stick| store << hexagram1_key[stick] + "\n"}
  else
    hex.inject('') {|store, stick| store << hexagram2_key[stick] + "\n"}
  end
end