class RandomWords::Generator
def initialize(source = :english, options = {})
-
_options(Hash) -- Options for the generator (e.g., length, paragraph_length) -
source(Symbol) -- The source of the words (e.g., :english)
def initialize(source = :english, options = {}) @source = source @nouns = from_file('nouns-singular.txt') @plural_nouns = from_file('nouns-plural.txt') @verbs = from_file('verbs-singular.txt') @plural_verbs = from_file('verbs-plural.txt') @passive_verbs = from_file('verbs-passive.txt') @adverbs = from_file('adverbs.txt') @adjectives = from_file('adjectives.txt') @articles = from_file('articles-singular.txt') @plural_articles = from_file('articles-plural.txt') @clauses = from_file('clauses.txt') @subordinate_conjunctions = from_file('conjunctions-subordinate.txt') @numbers = from_file('numbers.txt') @options = { sentence_length: :medium, paragraph_length: 5 } @options.merge!(options) if options.is_a?(Hash) @sentence_length = @options[:sentence_length] @paragraph_length = @options[:paragraph_length] lengths end