iching 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/iching.gemspec +1 -1
- data/lib/dictionaries.rb +80 -16
- data/lib/iching.rb +15 -20
- metadata +1 -1
data/iching.gemspec
CHANGED
data/lib/dictionaries.rb
CHANGED
@@ -1,25 +1,89 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Dictionaries
|
3
|
-
|
4
3
|
def hex
|
5
4
|
6.times.map{ Random.new.rand(6..9) }.reverse
|
6
5
|
end
|
7
6
|
|
8
7
|
def list
|
9
|
-
{'111111'=> '1. Force (乾 qián); The Creative; Possessing Creative Power & Skill',
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
{ '111111'=> '1. Force (乾 qián); The Creative; Possessing Creative Power & Skill',
|
9
|
+
'000000'=> '2. Field (坤 kūn); The Receptive; Needing Knowledge & Skill; Do not force matters and go with the flow',
|
10
|
+
'100010'=> '3. Sprouting (屯 zhūn); Difficulty at the Beginning; Sprouting ',
|
11
|
+
'010001'=> '4. Enveloping (蒙 méng); Youthful Folly; Detained, Enveloped and Inexperienced',
|
12
|
+
'111010'=> '5. Attending (需 xū); Waiting; Uninvolvement (Wait for now), Nourishment ',
|
13
|
+
'010111'=> '6. Arguing (訟 sòng); Conflict; Engagement in Conflict ',
|
14
|
+
'010000'=> '7. Leading (師 shī); The Army; Bringing Together, Teamwork ',
|
15
|
+
'000010'=> '8. Grouping (比 bǐ); Holding Together; Union ',
|
16
|
+
'111011'=> '9. Small Accumulating (小畜 xiǎo chù); Small Taming; Accumulating Resources',
|
17
|
+
'110111'=> '10. Treading (履 lǚ); Treading (Conduct); Continuing with Alertness',
|
18
|
+
'111000'=> '11. Pervading (泰 tài); Peace; Pervading',
|
19
|
+
'000111'=> '12. Obstruction (否 pǐ); Standstill; Stagnation',
|
20
|
+
'101111'=> '13. Concording People (同人 tóng rén); Fellowship; Fellowship, Partnership',
|
21
|
+
'111101'=> '14. Great Possessing (大有 dà yǒu); Great Possession; Independence, Freedom',
|
22
|
+
'001000'=> '15. Humbling (謙 qiān); Modesty; Being Reserved, Refraining',
|
23
|
+
'000100'=> '16. Providing-For (豫 yù); Enthusiasm; Inducement, New Stimulus',
|
24
|
+
'100110'=> '17. Following (隨 suí); Following; Following',
|
25
|
+
'011001'=> '18. Corrupting (蠱 gǔ); Work on the Decayed; Repairing',
|
26
|
+
'110000'=> '19. Nearing (臨 lín); Approach; Approaching Goal, Arriving ',
|
27
|
+
'000011'=> '20. Viewing (觀 guān); Contemplation; The Withholding',
|
28
|
+
'100101'=> '21. Gnawing Bite (噬嗑 shì kè); Biting Through; Deciding',
|
29
|
+
'101001'=> '22. Adorning (賁 bì); Grace; Embellishing',
|
30
|
+
'000001'=> '23. Stripping (剝 bō); Splitting Apart; Stripping, Flaying',
|
31
|
+
'100000'=> '24. Returning (復 fù); Return; Returning',
|
32
|
+
'100111'=> '25. Without Embroiling (無妄 wú wàng); Innocence; Without Rashness',
|
33
|
+
'111001'=> '26. Great Accumulating (大畜 dà chù); Great Taming; Accumulating Wisdom',
|
34
|
+
'100001'=> '27. Swallowing (頤 yí); Mouth Corners; Seeking Nourishment',
|
35
|
+
'011110'=> '28. Great Exceeding (大過 dà guò); Great Preponderance; Great Surpassing',
|
36
|
+
'010010'=> '29. Gorge (坎 kǎn); The Abysmal Water; Darkness, Gorge',
|
37
|
+
'101101'=> '30. Radiance (離 lí); The Clinging; Clinging, Attachment',
|
38
|
+
'001110'=> '31. Conjoining (咸 xián); Influence; Attraction',
|
39
|
+
'011100'=> '32. Persevering (恆 héng); Duration; Perseverance',
|
40
|
+
'001111'=> '33. Retiring (遯 dùn); Retreat; Withdrawing',
|
41
|
+
'111100'=> '34. Great Invigorating (大壯 dà zhuàng); Great Power; Great Boldness',
|
42
|
+
'000101'=> '35. Prospering (晉 jìn); Progress; Expansion, Promotion',
|
43
|
+
'101000'=> '36. Brightness Hiding (明夷 míng yí); Darkening of the Light; Brilliance Injured',
|
44
|
+
'101011'=> '37. Dwelling People (家人 jiā rén); The Family; Family',
|
45
|
+
'110101'=> '38. Polarising (睽 kuí); Opposition; Division, Divergence',
|
46
|
+
'001010'=> '39. Limping (蹇 jiǎn); Obstruction; Halting, Hardship',
|
47
|
+
'010100'=> '40. Taking-Apart (解 xiè); Deliverance; Liberation, Solution',
|
48
|
+
'110001'=> '41. Diminishing (損 sǔn); Decrease; Decrease',
|
49
|
+
'100011'=> '42. Augmenting (益 yì); Increase; Increase',
|
50
|
+
'111110'=> '43. Parting (夬 guài); Breakthrough; Separation',
|
51
|
+
'011111'=> '44. Coupling (姤 gòu); Coming to Meet; Encountering',
|
52
|
+
'000110'=> '45. Clustering (萃 cuì); Gathering Together; Association, Companionship',
|
53
|
+
'011000'=> '46. Ascending (升 shēng); Pushing Upward; Growing Upward',
|
54
|
+
'010110'=> '47. Confining (困 kùn); Oppression; Exhaustion',
|
55
|
+
'011010'=> '48. Welling (井 jǐng); The Well; Replenishing, Renewal',
|
56
|
+
'101110'=> '49. Skinning (革 gé); Revolution; Abolishing the Old',
|
57
|
+
'011101'=> '50. Holding (鼎 dǐng); The Cauldron; Establishing the New',
|
58
|
+
'100100'=> '51. Shake (震 zhèn); Arousing; Mobilizing',
|
59
|
+
'001001'=> '52. Bound (艮 gèn); The Keeping Still; Immobility',
|
60
|
+
'001011'=> '53. Infiltrating (漸 jiàn); Development; Auspicious Outlook, Infiltration',
|
61
|
+
'110100'=> '54. Converting The Maiden (歸妹 guī mèi); The Marrying Maiden; Marrying',
|
62
|
+
'101100'=> '55. Abounding (豐 fēng); Abundance; Goal Reached,Ambition Achieved',
|
63
|
+
'001101'=> '56. Sojourning (旅 lǚ); The Wanderer; Travel',
|
64
|
+
'011011'=> '57. Ground (巽 xùn); The Gentle; Subtle Influence',
|
65
|
+
'110110'=> '58. Open (兌 duì); The Joyous; Overt Influence',
|
66
|
+
'010011'=> '59. Dispersing (渙 huàn); Dispersion; Dispersal',
|
67
|
+
'110010'=> '60. Articulating (節 jié); Limitation; Discipline',
|
68
|
+
'110011'=> '61. Centre Confirming (中孚 zhōng fú); Inner Truth; Staying Focused,Avoid Misrepresentation',
|
69
|
+
'001100'=> '62. Small Exceeding (小過 xiǎo guò); Small Preponderance; Small Surpassing',
|
70
|
+
'101010'=> '63. Already_Fording (既濟 jì jì); After Completion; Completion',
|
71
|
+
'010101'=> '64. Not-Yet Fording (未濟 wèi jì); Before Completion; Incompletion'}
|
72
|
+
end
|
18
73
|
|
19
|
-
|
20
|
-
|
21
|
-
|
74
|
+
def hexagram1_key
|
75
|
+
{ 6 => '-- --', 7 => '-----', 8 => '-- --', 9 => '-----'}
|
76
|
+
end
|
22
77
|
|
23
|
-
|
24
|
-
|
25
|
-
|
78
|
+
def hexagram2_key
|
79
|
+
{ 6 => '-----', 7 => '-----', 8 => '-- --', 9 => '-- --'}
|
80
|
+
end
|
81
|
+
|
82
|
+
def binhex1_key
|
83
|
+
{ 6 => '0', 7 => '1', 8 => '0', 9 => '1'}
|
84
|
+
end
|
85
|
+
|
86
|
+
def binhex2_key
|
87
|
+
{ 6 => '1', 7 => '1', 8 => '0', 9 => '0'}
|
88
|
+
end
|
89
|
+
end
|
data/lib/iching.rb
CHANGED
@@ -13,33 +13,28 @@ class Iching
|
|
13
13
|
|
14
14
|
def display
|
15
15
|
if Random.new.rand(1..20) > 1
|
16
|
-
puts hex_symbol, hex_name, hex_symbol(
|
16
|
+
puts hex_symbol, hex_name, hex_symbol(2), hex_name(2)
|
17
17
|
else
|
18
18
|
puts "A suffusion of yellow."
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def hex_name(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
hex.each {|stick| bin_hex << binhex2_key[stick]}
|
29
|
-
end
|
22
|
+
def hex_name(second = false)
|
23
|
+
unless second
|
24
|
+
bin_hex = hex.inject('') {|store,stick| store << binhex1_key[stick]}
|
25
|
+
else
|
26
|
+
bin_hex = hex.inject('') {|store,stick| store << binhex1_key[stick]}
|
27
|
+
end
|
30
28
|
bin_hex.reverse!
|
31
29
|
return list[bin_hex]
|
32
30
|
end
|
33
|
-
|
34
|
-
def hex_symbol(
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
return symbol
|
43
|
-
end
|
31
|
+
|
32
|
+
def hex_symbol(second = false)
|
33
|
+
unless second
|
34
|
+
hex.inject('') {|store, stick| store << hexagram1_key[stick] + "\n"}
|
35
|
+
else
|
36
|
+
hex.inject('') {|store, stick| store << hexagram2_key[stick] + "\n"}
|
37
|
+
end
|
38
|
+
end
|
44
39
|
|
45
40
|
end
|