Module: IChing::Caster

Extended by:
Caster
Included in:
Caster
Defined in:
lib/i_ching/caster.rb

Defined Under Namespace

Classes: InvalidCaster

Instance Method Summary collapse

Instance Method Details

#available_casting_method(method) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/i_ching/caster.rb', line 15

def available_casting_method(method)
  case method.to_sym
  when :yarrow then IChing::Casters::Yarrow
  when :coins then IChing::Casters::Coins
  when :random then IChing::Casters::Random
  else nil
  end
end

#with_method(method) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/i_ching/caster.rb', line 7

def with_method(method)
  if casting_method = available_casting_method(method)
    casting_method.new
  else
    raise InvalidCaster
  end
end