Class: Zenlish::Inflect::InflectionRule
- Inherits:
-
Object
- Object
- Zenlish::Inflect::InflectionRule
- Defined in:
- lib/zenlish/inflect/inflection_rule.rb
Overview
An inflection rule has two-parts:
- a set of input conditions
- a consequent part which tells how to inflect a lexeme
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#consequent ⇒ Object
readonly
Returns the value of attribute consequent.
Instance Method Summary collapse
- #apply(theHeadings, aLexeme, actuals) ⇒ Object
- #force_apply(theHeadings, aLexeme) ⇒ Object
-
#initialize(theConditions, aConsequentExpr) ⇒ InflectionRule
constructor
A new instance of InflectionRule.
- #success?(theHeadings, aLexeme, actuals) ⇒ Boolean
Constructor Details
#initialize(theConditions, aConsequentExpr) ⇒ InflectionRule
Returns a new instance of InflectionRule.
10 11 12 13 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 10 def initialize(theConditions, aConsequentExpr) @conditions = theConditions @consequent = aConsequentExpr end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
7 8 9 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 7 def conditions @conditions end |
#consequent ⇒ Object (readonly)
Returns the value of attribute consequent.
8 9 10 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 8 def consequent @consequent end |
Instance Method Details
#apply(theHeadings, aLexeme, actuals) ⇒ Object
19 20 21 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 19 def apply(theHeadings, aLexeme, actuals) consequent.generate(theHeadings, aLexeme, actuals) end |
#force_apply(theHeadings, aLexeme) ⇒ Object
23 24 25 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 23 def force_apply(theHeadings, aLexeme) consequent.generate(theHeadings, aLexeme) end |
#success?(theHeadings, aLexeme, actuals) ⇒ Boolean
15 16 17 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 15 def success?(theHeadings, aLexeme, actuals) conditions.all? { |cond| cond.success?(theHeadings, aLexeme, actuals) } end |