Sha256: 3416f66caccf5c5845b68ba74f8aee4ac6f622a9c304dd54700b1e4b3e239ea5
Contents?: true
Size: 1.19 KB
Versions: 4
Compression:
Stored size: 1.19 KB
Contents
require_relative 'lexical_verb' require_relative 'irregular_verb_extension' module Zenlish module WClasses module IrregularVerbExtension # This callback when the module is extending an object. # Purpose: to inject a number of instance variables in the host # def extended(host) def init_extension(host) host.instance_variable_set(:@forms, []) end # @param theForm [Hash{Symbol => String}] def forms(theForms) valid_symbols = [:past_simple, :past_participle] actual_symbols = theForms.keys actual_symbols.each do |symb| raise StandardError, "Invalid verb form #{symb}" unless valid_symbols.include?(symb) end if actual_symbols.size < valid_symbols.size missing = valid_symbols.find { |symb| !actual_symbols.include?(symb) } raise StandardError, "Missing form #{missing}" end @forms = [nil, nil] @forms[0] = theForms[valid_symbols[0]] @forms[1] = theForms[valid_symbols[1]] end def past_simple @forms.first end def past_participle @forms.last end end # class end # module end # module
Version data entries
4 entries across 4 versions & 1 rubygems