iching 0.1.0 → 0.3.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cff67291520838e0821b0e0648424d8beba77a291a64ee051753a5883b39418a
4
+ data.tar.gz: da51e48699b6ab49bd6ec874672d4b23e7aa46f6215ce6e1ec9323fe6adb3de6
5
+ SHA512:
6
+ metadata.gz: 9d5bbebbd7b3195f58554c1bdb5e3d8ac3f70fa5507990585e0c29872b5621b51ffe179d8c6b5a20b9bf437daf9ff3cbe7a94eed277f533a6dfe61cd7218639e
7
+ data.tar.gz: 24d2b091dbd5af5bc0b27e7aaed93cb9b47586e4c69ffe7657bb4bf8cac6c6c5ca664755c2cf77553f030685205a2c8c852145d94a7d793b1d08661b4fbff0ad
@@ -0,0 +1,4 @@
1
+ pkg
2
+ doc
3
+ Manifest
4
+ .DS_Store
@@ -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.1.0"
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.3.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.10"
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,70 @@
1
+ # encoding: UTF-8
2
+ module Dictionaries
3
+
4
+ def list
5
+ { '111111'=> '1. Force (乾 qián); The Creative; Possessing Creative Power & Skill',
6
+ '000000'=> '2. Field (坤 kūn); The Receptive; Needing Knowledge & Skill; Do not force matters and go with the flow',
7
+ '100010'=> '3. Sprouting (屯 zhūn); Difficulty at the Beginning; Sprouting ',
8
+ '010001'=> '4. Enveloping (蒙 méng); Youthful Folly; Detained, Enveloped and Inexperienced',
9
+ '111010'=> '5. Attending (需 xū); Waiting; Uninvolvement (Wait for now), Nourishment ',
10
+ '010111'=> '6. Arguing (訟 sòng); Conflict; Engagement in Conflict ',
11
+ '010000'=> '7. Leading (師 shī); The Army; Bringing Together, Teamwork ',
12
+ '000010'=> '8. Grouping (比 bǐ); Holding Together; Union ',
13
+ '111011'=> '9. Small Accumulating (小畜 xiǎo chù); Small Taming; Accumulating Resources',
14
+ '110111'=> '10. Treading (履 lǚ); Treading (Conduct); Continuing with Alertness',
15
+ '111000'=> '11. Pervading (泰 tài); Peace; Pervading',
16
+ '000111'=> '12. Obstruction (否 pǐ); Standstill; Stagnation',
17
+ '101111'=> '13. Concording People (同人 tóng rén); Fellowship; Fellowship, Partnership',
18
+ '111101'=> '14. Great Possessing (大有 dà yǒu); Great Possession; Independence, Freedom',
19
+ '001000'=> '15. Humbling (謙 qiān); Modesty; Being Reserved, Refraining',
20
+ '000100'=> '16. Providing-For (豫 yù); Enthusiasm; Inducement, New Stimulus',
21
+ '100110'=> '17. Following (隨 suí); Following; Following',
22
+ '011001'=> '18. Corrupting (蠱 gǔ); Work on the Decayed; Repairing',
23
+ '110000'=> '19. Nearing (臨 lín); Approach; Approaching Goal, Arriving ',
24
+ '000011'=> '20. Viewing (觀 guān); Contemplation; The Withholding',
25
+ '100101'=> '21. Gnawing Bite (噬嗑 shì kè); Biting Through; Deciding',
26
+ '101001'=> '22. Adorning (賁 bì); Grace; Embellishing',
27
+ '000001'=> '23. Stripping (剝 bō); Splitting Apart; Stripping, Flaying',
28
+ '100000'=> '24. Returning (復 fù); Return; Returning',
29
+ '100111'=> '25. Without Embroiling (無妄 wú wàng); Innocence; Without Rashness',
30
+ '111001'=> '26. Great Accumulating (大畜 dà chù); Great Taming; Accumulating Wisdom',
31
+ '100001'=> '27. Swallowing (頤 yí); Mouth Corners; Seeking Nourishment',
32
+ '011110'=> '28. Great Exceeding (大過 dà guò); Great Preponderance; Great Surpassing',
33
+ '010010'=> '29. Gorge (坎 kǎn); The Abysmal Water; Darkness, Gorge',
34
+ '101101'=> '30. Radiance (離 lí); The Clinging; Clinging, Attachment',
35
+ '001110'=> '31. Conjoining (咸 xián); Influence; Attraction',
36
+ '011100'=> '32. Persevering (恆 héng); Duration; Perseverance',
37
+ '001111'=> '33. Retiring (遯 dùn); Retreat; Withdrawing',
38
+ '111100'=> '34. Great Invigorating (大壯 dà zhuàng); Great Power; Great Boldness',
39
+ '000101'=> '35. Prospering (晉 jìn); Progress; Expansion, Promotion',
40
+ '101000'=> '36. Brightness Hiding (明夷 míng yí); Darkening of the Light; Brilliance Injured',
41
+ '101011'=> '37. Dwelling People (家人 jiā rén); The Family; Family',
42
+ '110101'=> '38. Polarising (睽 kuí); Opposition; Division, Divergence',
43
+ '001010'=> '39. Limping (蹇 jiǎn); Obstruction; Halting, Hardship',
44
+ '010100'=> '40. Taking-Apart (解 xiè); Deliverance; Liberation, Solution',
45
+ '110001'=> '41. Diminishing (損 sǔn); Decrease; Decrease',
46
+ '100011'=> '42. Augmenting (益 yì); Increase; Increase',
47
+ '111110'=> '43. Parting (夬 guài); Breakthrough; Separation',
48
+ '011111'=> '44. Coupling (姤 gòu); Coming to Meet; Encountering',
49
+ '000110'=> '45. Clustering (萃 cuì); Gathering Together; Association, Companionship',
50
+ '011000'=> '46. Ascending (升 shēng); Pushing Upward; Growing Upward',
51
+ '010110'=> '47. Confining (困 kùn); Oppression; Exhaustion',
52
+ '011010'=> '48. Welling (井 jǐng); The Well; Replenishing, Renewal',
53
+ '101110'=> '49. Skinning (革 gé); Revolution; Abolishing the Old',
54
+ '011101'=> '50. Holding (鼎 dǐng); The Cauldron; Establishing the New',
55
+ '100100'=> '51. Shake (震 zhèn); Arousing; Mobilizing',
56
+ '001001'=> '52. Bound (艮 gèn); The Keeping Still; Immobility',
57
+ '001011'=> '53. Infiltrating (漸 jiàn); Development; Auspicious Outlook, Infiltration',
58
+ '110100'=> '54. Converting The Maiden (歸妹 guī mèi); The Marrying Maiden; Marrying',
59
+ '101100'=> '55. Abounding (豐 fēng); Abundance; Goal Reached,Ambition Achieved',
60
+ '001101'=> '56. Sojourning (旅 lǚ); The Wanderer; Travel',
61
+ '011011'=> '57. Ground (巽 xùn); The Gentle; Subtle Influence',
62
+ '110110'=> '58. Open (兌 duì); The Joyous; Overt Influence',
63
+ '010011'=> '59. Dispersing (渙 huàn); Dispersion; Dispersal',
64
+ '110010'=> '60. Articulating (節 jié); Limitation; Discipline',
65
+ '110011'=> '61. Centre Confirming (中孚 zhōng fú); Inner Truth; Staying Focused,Avoid Misrepresentation',
66
+ '001100'=> '62. Small Exceeding (小過 xiǎo guò); Small Preponderance; Small Surpassing',
67
+ '101010'=> '63. Already_Fording (既濟 jì jì); After Completion; Completion',
68
+ '010101'=> '64. Not-Yet Fording (未濟 wèi jì); Before Completion; Incompletion'}
69
+ end
70
+ end
@@ -1,48 +1,53 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
- require 'rubygems'
2
+ require 'dictionaries.rb'
3
+
4
+ class Iching
5
+ def hex
6
+ @hex ||= 6.times.map{ Random.new.rand(6..9) }.reverse
7
+ end
8
+
9
+ def display
10
+ # puts "A suffusion of yellow." && return if Random.new.rand(1..20) <= 1
11
+ hex1 = Hex1.new(hex)
12
+ hex2 = Hex2.new(hex)
13
+ puts hex1.hex_symbol, hex1.hex_name, hex2.hex_symbol, hex2.hex_name
14
+ end
4
15
 
5
- #ruby version compatibility hax
6
- unless RUBY_VERSION.gsub(".","").to_i > 190
7
- require 'backports'
8
16
  end
9
17
 
18
+ class Hex1
19
+ include ::Dictionaries
10
20
 
11
- 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'}
21
+ attr_reader :hex
22
+
23
+ def initialize(hex)
24
+ @hex = hex
19
25
  end
20
- def display
21
- if Random.new.rand(1..20) > 1
22
- puts hex_symbol, hex_name, hex_symbol(1), hex_name(1)
23
- else
24
- puts "A suffusion of yellow."
25
- end
26
- 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
35
- bin_hex.reverse!
36
- return @list[bin_hex]
37
- 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
26
+
27
+ def bin_hex_key
28
+ { 6 => '0', 7 => '1', 8 => '0', 9 => '1'}
29
+ end
30
+
31
+ def hexagram_key
32
+ { 6 => '-- --', 7 => '-----', 8 => '-- --', 9 => '-----'}
33
+ end
34
+
35
+ def hex_symbol
36
+ hex.map{|n| hexagram_key[n] }.join("\n")
37
+ end
38
+
39
+ def hex_name
40
+ hex_binary = hex.map{|n| bin_hex_key[n]}.join("").reverse()
41
+ return list[hex_binary]
42
+ end
43
+ end
44
+
45
+ class Hex2 < Hex1
46
+ def bin_hex_key
47
+ { 6 => '1', 7 => '1', 8 => '0', 9 => '0'}
48
+ end
49
+
50
+ def hexagram_key
51
+ { 6 => '-----', 7 => '-----', 8 => '-- --', 9 => '-- --'}
52
+ end
53
+ 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,70 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iching
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matt Mills
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-10-08 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: backports
16
- requirement: &2153506040 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *2153506040
11
+ date: 2021-01-02 00:00:00.000000000 Z
12
+ dependencies: []
25
13
  description: Generate an Iching hexagram and access various things about it.
26
- email: sunrisetimes@gmail.com
14
+ email:
15
+ - sunrisetimes@gmail.com
27
16
  executables:
28
17
  - iching
29
18
  extensions: []
30
- extra_rdoc_files:
31
- - bin/iching
32
- - lib/iching.rb
19
+ extra_rdoc_files: []
33
20
  files:
21
+ - ".gitignore"
34
22
  - Rakefile
35
23
  - bin/iching
36
- - lib/iching.rb
37
- - readme.markdown
38
- - Manifest
39
24
  - iching.gemspec
40
- homepage: https://github.com/mattmills/iching
41
- licenses: []
42
- post_install_message:
43
- rdoc_options:
44
- - --line-numbers
45
- - --inline-source
46
- - --title
47
- - Iching
48
- - --main
25
+ - lib/dictionaries.rb
26
+ - lib/iching.rb
49
27
  - readme.markdown
28
+ homepage: http://github.com/mattmills/iching
29
+ licenses:
30
+ - MIT
31
+ metadata: {}
32
+ post_install_message:
33
+ rdoc_options: []
50
34
  require_paths:
51
35
  - lib
52
36
  required_ruby_version: !ruby/object:Gem::Requirement
53
- none: false
54
37
  requirements:
55
- - - ! '>='
38
+ - - ">="
56
39
  - !ruby/object:Gem::Version
57
40
  version: '0'
58
41
  required_rubygems_version: !ruby/object:Gem::Requirement
59
- none: false
60
42
  requirements:
61
- - - ! '>='
43
+ - - ">="
62
44
  - !ruby/object:Gem::Version
63
- version: '1.2'
45
+ version: '0'
64
46
  requirements: []
65
- rubyforge_project: iching
66
- rubygems_version: 1.8.10
67
- signing_key:
68
- specification_version: 3
69
- summary: Generate an Iching hexagram and access various things about it.
47
+ rubygems_version: 3.2.3
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: tell the future (but not really)
70
51
  test_files: []
data/Manifest DELETED
@@ -1,5 +0,0 @@
1
- Rakefile
2
- bin/iching
3
- lib/iching.rb
4
- readme.markdown
5
- Manifest