Class: Hex1

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

Direct Known Subclasses

Hex2

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Dictionaries

#list

Constructor Details

#initialize(hex) ⇒ Hex1

Returns a new instance of Hex1.



23
24
25
# File 'lib/iching.rb', line 23

def initialize(hex)
  @hex = hex
end

Instance Attribute Details

#hexObject (readonly)

Returns the value of attribute hex.



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

def hex
  @hex
end

Instance Method Details

#bin_hex_keyObject



27
28
29
# File 'lib/iching.rb', line 27

def bin_hex_key
  { 6 => '0', 7 => '1', 8 => '0', 9 => '1'}
end

#hex_nameObject



39
40
41
42
# File 'lib/iching.rb', line 39

def hex_name
  hex_binary = hex.map{|n| bin_hex_key[n]}.join("").reverse()
  return list[hex_binary]
end

#hex_symbolObject



35
36
37
# File 'lib/iching.rb', line 35

def hex_symbol
  hex.map{|n| hexagram_key[n] }.join("\n")
end

#hexagram_keyObject



31
32
33
# File 'lib/iching.rb', line 31

def hexagram_key
  { 6 => '-- --', 7 => '-----', 8 => '-- --', 9 => '-----'}
end