Sha256: c71e52335d4bdfcd8d3ab3c05a02468230695139a8fb521a54ba38b9c641d886

Contents?: true

Size: 798 Bytes

Versions: 6

Compression:

Stored size: 798 Bytes

Contents

module Zenlish
  module Inflect
    # An inflection rule has two-parts:
    # - a set of input conditions
    # - a consequent part which tells how to inflect a lexeme
    class InflectionRule
      attr_reader :conditions
      attr_reader :consequent

      def initialize(theConditions, aConsequentExpr)
        @conditions = theConditions
        @consequent = aConsequentExpr
      end

      def success?(theHeadings, aLexeme, actuals)
        conditions.all? { |cond| cond.success?(theHeadings, aLexeme, actuals) }
      end

      def apply(theHeadings, aLexeme, actuals)
        consequent.generate(theHeadings, aLexeme, actuals)
      end

      def force_apply(theHeadings, aLexeme)
        consequent.generate(theHeadings, aLexeme)
      end
    end # class
  end # module
end # module

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zenlish-0.2.05 lib/zenlish/inflect/inflection_rule.rb
zenlish-0.2.04 lib/zenlish/inflect/inflection_rule.rb
zenlish-0.2.03 lib/zenlish/inflect/inflection_rule.rb
zenlish-0.2.02 lib/zenlish/inflect/inflection_rule.rb
zenlish-0.2.01 lib/zenlish/inflect/inflection_rule.rb
zenlish-0.2.00 lib/zenlish/inflect/inflection_rule.rb