class Object

Public Instance Methods

Connie(argument, options={}) click to toggle source

The shorthand method to use connie Accepts three kinds of arguments:

1) String

Connie parses the string replacing the :dictionary.format bits of string with random
results from it's dictionaries

2) Symbols

Uses the symbol to pick the dictionary to return and eventually calls the format on 
it.

3) Arrays

As a form of convenience Connie picks a random element out of the array passed
# File lib/connie.rb, line 46
def Connie(argument, options={})
  case argument
  when String
    Connie::Parser.process(argument)
  when Symbol
    argument = argument.to_s.split('.').map &:to_sym
    
    dictionary = Connie[argument.first]
    
    if argument[1]
      dictionary.send argument[1], options
    else
      dictionary
    end
  when Array
    argument[rand(argument.size)]
  when Range
    rand(argument.max-argument.min+1) + argument.min
  else
    raise ArgumentError, 'Connie\'s shorthand expects a string to parse or a symbol or an array'
  end
end
Connie?() click to toggle source
# File lib/connie.rb, line 69
def Connie?
  [true,false][rand 2]
end