Class: IChing::CastHexagram
- Inherits:
-
Object
- Object
- IChing::CastHexagram
- Defined in:
- lib/i_ching/cast_hexagram.rb
Defined Under Namespace
Classes: InvalidCast
Constant Summary collapse
- CHANGES =
{ 6 => 7, 9 => 8 }
- STABILIZATIONS =
{ 6 => 8, 9 => 7 }
- BINARY =
{ 7 => 1, 8 => 0 }
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
Instance Method Summary collapse
- #binary ⇒ Object
- #change ⇒ Object
- #changed_hexagram ⇒ Object
- #hexagram ⇒ Object
-
#initialize(*lines) ⇒ CastHexagram
constructor
A new instance of CastHexagram.
- #stabilize ⇒ Object
Constructor Details
#initialize(*lines) ⇒ CastHexagram
Returns a new instance of CastHexagram.
22 23 24 25 |
# File 'lib/i_ching/cast_hexagram.rb', line 22 def initialize(*lines) @lines = lines validate end |
Instance Attribute Details
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
20 21 22 |
# File 'lib/i_ching/cast_hexagram.rb', line 20 def lines @lines end |
Instance Method Details
#binary ⇒ Object
35 36 37 |
# File 'lib/i_ching/cast_hexagram.rb', line 35 def binary stabilize.lines.map { |line| BINARY[line] }.join("").to_i(2) end |
#change ⇒ Object
27 28 29 |
# File 'lib/i_ching/cast_hexagram.rb', line 27 def change CastHexagram.new(*process(CHANGES)) end |
#changed_hexagram ⇒ Object
43 44 45 |
# File 'lib/i_ching/cast_hexagram.rb', line 43 def changed_hexagram change.hexagram end |
#hexagram ⇒ Object
39 40 41 |
# File 'lib/i_ching/cast_hexagram.rb', line 39 def hexagram Hexagram.get_by_binary(self.binary) end |
#stabilize ⇒ Object
31 32 33 |
# File 'lib/i_ching/cast_hexagram.rb', line 31 def stabilize CastHexagram.new(*process(STABILIZATIONS)) end |