Sha256: f6c4a9dedb8cf5c065403f2bb5f90b7f8cf5664a2178e89c63263bda20558416

Contents?: true

Size: 461 Bytes

Versions: 1

Compression:

Stored size: 461 Bytes

Contents

require 'cowsay/version'
require 'cowsay/character'

module ::Cowsay
  module_function # all instance methods are available on the module (class) level

  def random_character
    random_class = Character.const_get(character_classes[rand(character_classes.length)])
    random_class.new
  end

  def character_classes
    @character_classes ||= Character.constants - [:Base, :Template]
  end

  def say(message)
    puts random_character.say(message)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cowsay-0.0.2 lib/cowsay.rb