Module: ZenAndMusashi::LocalWisdom

Defined in:
lib/zen_and_musashi/local_wisdom.rb

Class Method Summary collapse

Class Method Details

.invoke(mode, _input) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/zen_and_musashi/local_wisdom.rb', line 10

def invoke(mode, _input)
  store = Store.new

  # 初回実行時にseed投入
  Seed.run(store) if store.count(mode).zero?

  quote = store.random(mode)

  if quote.nil?
    "No quotes found for #{mode} mode. Add one with: musashi add \"your quote\" --mode #{mode}"
  else
    quote[:text]
  end
end