Sha256: 2381ea6da030a45e73a02800dae46cb9a2c2f784db50233dff6c3ed62b70cd73

Contents?: true

Size: 898 Bytes

Versions: 12

Compression:

Stored size: 898 Bytes

Contents

require 'gamefic'
require 'gamefic/grammar'

module Gamefic::Grammar
  class Verbs
    extend Gamefic::Grammar::Conjugator::ClassMethods
    def initialize obj
      @pronoun = obj
      self.class.conjugated_verbs.each_pair { |infinitive, verbset|
        define_singleton_method infinitive do
          verbset[:present].conjugate @pronoun
        end
      }
    end
    def method_missing infinitive, *args, &block
      Gamefic::Grammar::VerbSet.new(infinitive, nil, *args).conjugate(@pronoun)
    end
    def [] infinitive
      words = infinitive.split_words
      Gamefic::Grammar::VerbSet.new(words[0], nil).conjugate(@pronoun) + (words.length > 1 ? ' ' + words[1..-1].join(' ') : '')
    end
    conjugate :be,   :present, :am,   :are,  :is,  :are
    conjugate :have, :present, :have, :have, :has, :have
    conjugate :can, :present, :can, :can, :can
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gamefic-1.7.0 lib/gamefic/grammar/verbs.rb
gamefic-1.6.0 lib/gamefic/grammar/verbs.rb
gamefic-1.5.1 lib/gamefic/grammar/verbs.rb
gamefic-1.5.0 lib/gamefic/grammar/verbs.rb
gamefic-1.4.1 lib/gamefic/grammar/verbs.rb
gamefic-1.4.0 lib/gamefic/grammar/verbs.rb
gamefic-1.3.2 lib/gamefic/grammar/verbs.rb
gamefic-1.3.1 lib/gamefic/grammar/verbs.rb
gamefic-1.3.0 lib/gamefic/grammar/verbs.rb
gamefic-1.2.0 lib/gamefic/grammar/verbs.rb
gamefic-1.1.0 lib/gamefic/grammar/verbs.rb
gamefic-1.0.0 lib/gamefic/grammar/verbs.rb