This library allows you to cast hexagrams from the _Book of Changes_
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
samples
tests
.gitignore
MIT-LICENSE
README.rdoc
Rakefile

README.rdoc

IChing

DESCRIPTION:

I Ching allows you to easily cast hexagrams from _The Book of Changes_

FEATURES:

  • Utilizes the Yarrow Stalk casting method described in the appendix of _The I Ching (or Book of Changes)_ by Richard Wilhelm.

  • Names and rudimentary descriptions for all generated hexagrams.

  • Easily determine the nuclear trigrams of a given hexagram.

  • Easily determine if a hexagram is moving, obtain the moving lines, or generate the changed hexagram.

  • Render a hexagram to a string.

TODO:

  • Further tests, optimizations, beautification.

SYNOPSIS:

Casting hexagrams is easy:

require 'iching'

cast = IChing::Cast.new
cast.hexagrams.each do | hexagram |
  puts
  puts hexagram.to_s
  puts hexagram.description[:name]
  hexagram.moving_lines.each { | line | puts "Lines #{ line }" }
end

Example output:

-------
-------
--- ---
-------
---x---
--- ---
Chien
Lines 2

-------
-------
--- ---
-------
-------
--- ---
Sun

Once cast, you can query a hexagram for details:

cast = IChing::Cast.new
hexagram = cast.hexagrams.first

puts hexagram.to_s

  -------
  -------
  --- ---
  -------
  ---x---
  --- ---

puts hexagram.description[:name]

  Chien

puts hexagram.moving_lines

  2

puts hexagram.signature.to_s

  001011

puts hexagram.top_trigram.to_s

  -------
  -------
  --- ---

puts hexagram.top_trigram.description[:name]

  Sun

puts hexagram.top_trigram.signature.to_s

  001

puts hexagram.bottom_trigram.to_s

  -------
  --- ---
  --- ---

puts hexagram.bottom_trigram.description[:name]

  Ken

puts hexagram.bottom_trigram.signature.to_s

  011

FURTHER READING:

_The I Ching (or Book of Changes)_ by Richard Wilhelm

LICENSE:

(The MIT License)

Copyright © 2008 Jon Fuller (ratchetcat+github@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.