Class: Xsay::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/xsay.rb

Constant Summary collapse

ANIMALS =
Dir[File.expand_path("xsay/templates/*.template", File.dirname(__FILE__))]

Instance Method Summary collapse

Instance Method Details

#all(*args) ⇒ Object



23
24
25
26
27
# File 'lib/xsay.rb', line 23

def all(*args)
  animals = public_methods - Thor.new.methods - [:random, :all]
  animals.each { |x| public_send(x, *args) }
  nil
end

#random(*args) ⇒ Object



30
31
32
33
# File 'lib/xsay.rb', line 30

def random(*args)
  random_colour = (String.colors + [:rainbow]).sample
  renderer(random_colour).render(args, IO.read(ANIMALS.shuffle.sample))
end