Module: TAROT

Defined in:
lib/toychest/tarot.rb

Defined Under Namespace

Classes: Tarot

Class Method Summary collapse

Class Method Details

.cards(*n, &b) ⇒ Object



6
7
8
9
10
# File 'lib/toychest/tarot.rb', line 6

def self.cards *n, &b
  dir, a = [], []; (n[0] || 1).times { dir << ['up', 'rev'].sample }
  Tarot.get("/api/v1/cards/random?n=#{n[0] || 1}")['cards'].each_with_index { |e,i| e['direction'] = dir[i]; a << b.call(e) }
  return a
end

.reading(*n) ⇒ Object



11
12
13
# File 'lib/toychest/tarot.rb', line 11

def self.reading *n
  TAROT.cards(n[0]) { |e| x = e["meaning_#{e['direction']}"]; %[#{e['name']} (#{e['direction']}) - #{x}] }
end