iching 0.0.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 567e0c98f1b44a86ebdc288e809e6172e639a0d4c5eab59cd439fd30ce9a607a
4
+ data.tar.gz: 39f7e2a9e4dbeaf798b1edd9efb8147f825d5295626c32eb0726f9262adef374
5
+ SHA512:
6
+ metadata.gz: 8bac72fe8e70ebfd6ebb418e6eb117426c2d244735f8922e4db54b342030956895fe49670020e86172421d8fa1476732a1b239a282cdf51ca299cf3e6cd29bbc
7
+ data.tar.gz: 745bf6b04d09f04a92a856c08857b755bc48a3115366c91b6e1fc527c2e89515b547afa2986a7f5dd00ba23aef316f85dfad1d335681d9a7b4aa9eb7849a7fd3
@@ -0,0 +1,4 @@
1
+ pkg
2
+ doc
3
+ Manifest
4
+ .DS_Store
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('iching', '0.0.6') do |p|
5
+ Echoe.new('iching', '0.1.0') do |p|
6
6
  p.description = "Generate an Iching hexagram and access various things about it."
7
7
  p.url = "https://github.com/mattmills/iching"
8
8
  p.author = "Matt Mills"
data/bin/iching CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: UTF-8
2
3
  require 'rubygems'
3
- require 'backports'
4
4
  require 'iching'
5
5
  Iching.new.display
@@ -1,33 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
-
3
2
  Gem::Specification.new do |s|
4
- s.name = "iching"
5
- s.version = "0.0.6"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Matt Mills"]
9
- s.date = "2011-10-08"
3
+ s.name = "iching"
4
+ s.version = "0.2.0"
5
+ s.platform = Gem::Platform::RUBY
6
+ s.authors = ["Matt Mills"]
7
+ s.email = ["sunrisetimes@gmail.com"]
8
+ s.homepage = "http://github.com/mattmills/iching"
9
+ s.summary = "tell the future (but not really)"
10
10
  s.description = "Generate an Iching hexagram and access various things about it."
11
- s.email = "sunrisetimes@gmail.com"
12
- s.executables = ["iching"]
13
- s.extra_rdoc_files = ["bin/iching", "lib/iching.rb"]
14
- s.files = ["Rakefile", "bin/iching", "lib/iching.rb", "readme.markdown", "Manifest", "iching.gemspec"]
15
- s.homepage = "https://github.com/mattmills/iching"
16
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Iching", "--main", "readme.markdown"]
11
+ s.files = `git ls-files`.split("\n")
12
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
13
  s.require_paths = ["lib"]
18
- s.rubyforge_project = "iching"
19
- s.rubygems_version = "1.8.11"
20
- s.summary = "Generate an Iching hexagram and access various things about it."
21
-
22
- if s.respond_to? :specification_version then
23
- s.specification_version = 3
24
-
25
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<backports>, [">= 0"])
27
- else
28
- s.add_dependency(%q<backports>, [">= 0"])
29
- end
30
- else
31
- s.add_dependency(%q<backports>, [">= 0"])
32
- end
14
+ s.license = 'MIT'
33
15
  end
@@ -0,0 +1,89 @@
1
+ # encoding: UTF-8
2
+ module Dictionaries
3
+ def hex
4
+ 6.times.map{ Random.new.rand(6..9) }.reverse
5
+ end
6
+
7
+ def list
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
73
+
74
+ def hexagram1_key
75
+ { 6 => '-- --', 7 => '-----', 8 => '-- --', 9 => '-----'}
76
+ end
77
+
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
@@ -1,48 +1,33 @@
1
- #!/usr/bin/env ruby
2
- require 'rubygems'
3
-
4
- #ruby version compatibility hax
5
- if RUBY_VERSION.gsub(".","").to_i > 191
6
- Encoding.default_internal = Encoding.find("UTF-8")
7
- else
8
- require 'backports'
9
- end
1
+ # encoding: UTF-8
2
+ require 'dictionaries.rb'
10
3
 
11
4
  class Iching
12
- def initialize()
13
- @hex = 6.times.map{ Random.new.rand(6..9) }.reverse
14
- @list = {'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'}
15
- @hexagram1_key = { 6 => '-- --', 7 => '-----', 8 => '-- --', 9 => '-----'}
16
- @hexagram2_key = { 6 => '-----', 7 => '-----', 8 => '-- --', 9 => '-- --'}
17
- @binhex1_key = { 6 => '0', 7 => '1', 8 => '0', 9 => '1'}
18
- @binhex2_key = { 6 => '1', 7 => '1', 8 => '0', 9 => '0'}
19
- end
5
+ include ::Dictionaries
6
+
20
7
  def display
21
- if Random.new.rand(1..20) > 1
22
- puts hex_symbol, hex_name, hex_symbol(1), hex_name(1)
8
+ @current_hex = hex()
9
+ if Random.new.rand(1..20) > 1
10
+ puts hex_symbol, hex_name, hex_symbol(2), hex_name(2)
23
11
  else
24
12
  puts "A suffusion of yellow."
25
13
  end
26
14
  end
27
- def hex_name(hex = 0)
28
- bin_hex = ''
29
- if hex == 0
30
- @hex.each {|stick| bin_hex << @binhex1_key[stick]}
31
- end
32
- if hex == 1
33
- @hex.each {|stick| bin_hex << @binhex2_key[stick]}
34
- end
15
+
16
+ def hex_name(second = false)
17
+ unless second
18
+ bin_hex = @current_hex.inject('') {|store,stick| store << binhex1_key[stick]}
19
+ else
20
+ bin_hex = @current_hex.inject('') {|store,stick| store << binhex1_key[stick]}
21
+ end
35
22
  bin_hex.reverse!
36
- return @list[bin_hex]
23
+ return list[bin_hex]
24
+ end
25
+
26
+ def hex_symbol(second = false)
27
+ unless second
28
+ @current_hex.inject('') {|store, stick| store << hexagram1_key[stick] + "\n"}
29
+ else
30
+ @current_hex.inject('') {|store, stick| store << hexagram2_key[stick] + "\n"}
31
+ end
37
32
  end
38
- def hex_symbol(hex = 0)
39
- symbol = ''
40
- if hex == 0
41
- @hex.each {|stick| symbol << @hexagram1_key[stick] + "\n"}
42
- end
43
- if hex == 1
44
- @hex.each {|stick| symbol << @hexagram2_key[stick] + "\n"}
45
- end
46
- return symbol
47
- end
48
- end
33
+ end
@@ -2,10 +2,5 @@
2
2
 
3
3
  This is a little program to cast I Ching hexagrams that I knocked together when I was first learning python, and have since improved at intervals when I was bored, and then I ported it to ruby, so you can use the class to get stuff about the hexagram, and use it in your awesome projects too. It depends on the backports gem for the random number generation, because I liked the way the new Random class from 1.9 works.
4
4
 
5
- ## Installation
6
-
7
- gem install backports
8
- gem install iching
9
-
10
5
  ## Usage
11
- There are class methods for accessing the symbol and the name of each hexagram, and also for displaying everything at once. It doesn't do much else right now. If you have any ideas, wants, or needs, let me know.
6
+ There are class methods for accessing the symbol and the name of each hexagram, and also for displaying everything at once. It doesn't do much else right now. If you have any ideas, wants, or needs, let me know.
metadata CHANGED
@@ -1,75 +1,51 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: iching
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Matt Mills
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-10-08 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: backports
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- type: :runtime
25
- version_requirements: *id001
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
+ dependencies: []
26
13
  description: Generate an Iching hexagram and access various things about it.
27
- email: sunrisetimes@gmail.com
28
- executables:
14
+ email:
15
+ - sunrisetimes@gmail.com
16
+ executables:
29
17
  - iching
30
18
  extensions: []
31
-
32
- extra_rdoc_files:
33
- - bin/iching
34
- - lib/iching.rb
35
- files:
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
36
22
  - Rakefile
37
23
  - bin/iching
24
+ - iching.gemspec
25
+ - lib/dictionaries.rb
38
26
  - lib/iching.rb
39
27
  - readme.markdown
40
- - Manifest
41
- - iching.gemspec
42
- homepage: https://github.com/mattmills/iching
43
- licenses: []
44
-
28
+ homepage: http://github.com/mattmills/iching
29
+ licenses:
30
+ - MIT
31
+ metadata: {}
45
32
  post_install_message:
46
- rdoc_options:
47
- - --line-numbers
48
- - --inline-source
49
- - --title
50
- - Iching
51
- - --main
52
- - readme.markdown
53
- require_paths:
33
+ rdoc_options: []
34
+ require_paths:
54
35
  - lib
55
- required_ruby_version: !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
58
38
  - - ">="
59
- - !ruby/object:Gem::Version
60
- version: "0"
61
- required_rubygems_version: !ruby/object:Gem::Requirement
62
- none: false
63
- requirements:
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
64
43
  - - ">="
65
- - !ruby/object:Gem::Version
66
- version: "1.2"
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
67
46
  requirements: []
68
-
69
- rubyforge_project: iching
70
- rubygems_version: 1.8.11
47
+ rubygems_version: 3.0.3
71
48
  signing_key:
72
- specification_version: 3
73
- summary: Generate an Iching hexagram and access various things about it.
49
+ specification_version: 4
50
+ summary: tell the future (but not really)
74
51
  test_files: []
75
-
data/Manifest DELETED
@@ -1,5 +0,0 @@
1
- Rakefile
2
- bin/iching
3
- lib/iching.rb
4
- readme.markdown
5
- Manifest