iching 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 567e0c98f1b44a86ebdc288e809e6172e639a0d4c5eab59cd439fd30ce9a607a
4
- data.tar.gz: 39f7e2a9e4dbeaf798b1edd9efb8147f825d5295626c32eb0726f9262adef374
3
+ metadata.gz: cff67291520838e0821b0e0648424d8beba77a291a64ee051753a5883b39418a
4
+ data.tar.gz: da51e48699b6ab49bd6ec874672d4b23e7aa46f6215ce6e1ec9323fe6adb3de6
5
5
  SHA512:
6
- metadata.gz: 8bac72fe8e70ebfd6ebb418e6eb117426c2d244735f8922e4db54b342030956895fe49670020e86172421d8fa1476732a1b239a282cdf51ca299cf3e6cd29bbc
7
- data.tar.gz: 745bf6b04d09f04a92a856c08857b755bc48a3115366c91b6e1fc527c2e89515b547afa2986a7f5dd00ba23aef316f85dfad1d335681d9a7b4aa9eb7849a7fd3
6
+ metadata.gz: 9d5bbebbd7b3195f58554c1bdb5e3d8ac3f70fa5507990585e0c29872b5621b51ffe179d8c6b5a20b9bf437daf9ff3cbe7a94eed277f533a6dfe61cd7218639e
7
+ data.tar.gz: 24d2b091dbd5af5bc0b27e7aaed93cb9b47586e4c69ffe7657bb4bf8cac6c6c5ca664755c2cf77553f030685205a2c8c852145d94a7d793b1d08661b4fbff0ad
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "iching"
4
- s.version = "0.2.0"
4
+ s.version = "0.3.0"
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ["Matt Mills"]
7
7
  s.email = ["sunrisetimes@gmail.com"]
@@ -1,9 +1,6 @@
1
1
  # encoding: UTF-8
2
2
  module Dictionaries
3
- def hex
4
- 6.times.map{ Random.new.rand(6..9) }.reverse
5
- end
6
-
3
+
7
4
  def list
8
5
  { '111111'=> '1. Force (乾 qián); The Creative; Possessing Creative Power & Skill',
9
6
  '000000'=> '2. Field (坤 kūn); The Receptive; Needing Knowledge & Skill; Do not force matters and go with the flow',
@@ -70,20 +67,4 @@ module Dictionaries
70
67
  '101010'=> '63. Already_Fording (既濟 jì jì); After Completion; Completion',
71
68
  '010101'=> '64. Not-Yet Fording (未濟 wèi jì); Before Completion; Incompletion'}
72
69
  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
70
  end
@@ -2,32 +2,52 @@
2
2
  require 'dictionaries.rb'
3
3
 
4
4
  class Iching
5
- include ::Dictionaries
5
+ def hex
6
+ @hex ||= 6.times.map{ Random.new.rand(6..9) }.reverse
7
+ end
6
8
 
7
9
  def display
8
- @current_hex = hex()
9
- if Random.new.rand(1..20) > 1
10
- puts hex_symbol, hex_name, hex_symbol(2), hex_name(2)
11
- else
12
- puts "A suffusion of yellow."
13
- end
14
- 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
22
- bin_hex.reverse!
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
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
15
+
16
+ end
17
+
18
+ class Hex1
19
+ include ::Dictionaries
20
+
21
+ attr_reader :hex
22
+
23
+ def initialize(hex)
24
+ @hex = hex
25
+ 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 => '-- --'}
32
52
  end
33
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iching
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Mills
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-14 00:00:00.000000000 Z
11
+ date: 2021-01-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generate an Iching hexagram and access various things about it.
14
14
  email:
@@ -29,7 +29,7 @@ homepage: http://github.com/mattmills/iching
29
29
  licenses:
30
30
  - MIT
31
31
  metadata: {}
32
- post_install_message:
32
+ post_install_message:
33
33
  rdoc_options: []
34
34
  require_paths:
35
35
  - lib
@@ -44,8 +44,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  requirements: []
47
- rubygems_version: 3.0.3
48
- signing_key:
47
+ rubygems_version: 3.2.3
48
+ signing_key:
49
49
  specification_version: 4
50
50
  summary: tell the future (but not really)
51
51
  test_files: []