iching 0.0.1

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