Sha256: 0517af4f3894759564acf214662f0c2c6b4748d95e99b7086bf410e49d092532
Contents?: true
Size: 1.06 KB
Versions: 5
Compression:
Stored size: 1.06 KB
Contents
require File.expand_path('word_type.rb', File.dirname(__FILE__)) module HaikuGadget class WordTemplate attr_reader :word_type, :obj_num attr_accessor :syllables, :plurality def initialize(base_symbol_or_word_type, syllables = 0, plurality = :none, obj_num = 0) if base_symbol_or_word_type.is_a? HaikuGadget::WordType # use provided (custom) WordType word_type = base_symbol_or_word_type else # look up word type based on symbol word_type = Dictionary::WORD_TYPES[base_symbol_or_word_type] end fail "unknown word type '#{base_symbol_or_word_type.to_s}'" unless word_type # check if template plurality needs to be set or changed if word_type.can_be_plural plurality = :any if plurality == :none else plurality = :none end @word_type = word_type @syllables = syllables @plurality = plurality @obj_num = obj_num end def self.custom(word_list, syllables) WordTemplate.new WordType.custom(word_list), syllables end end end
Version data entries
5 entries across 5 versions & 1 rubygems