iching 0.1.2 → 0.1.3

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