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.
12 13 14 15 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 12 def initialize(theConditions, aConsequentExpr) @conditions = theConditions @consequent = aConsequentExpr end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
9 10 11 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 9 def conditions @conditions end |
#consequent ⇒ Object (readonly)
Returns the value of attribute consequent.
10 11 12 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 10 def consequent @consequent end |
Instance Method Details
#apply(theHeadings, aLexeme, actuals) ⇒ Object
21 22 23 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 21 def apply(theHeadings, aLexeme, actuals) consequent.generate(theHeadings, aLexeme, actuals) end |
#force_apply(theHeadings, aLexeme) ⇒ Object
25 26 27 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 25 def force_apply(theHeadings, aLexeme) consequent.generate(theHeadings, aLexeme) end |
#success?(theHeadings, aLexeme, actuals) ⇒ Boolean
17 18 19 |
# File 'lib/zenlish/inflect/inflection_rule.rb', line 17 def success?(theHeadings, aLexeme, actuals) conditions.all? { |cond| cond.success?(theHeadings, aLexeme, actuals) } end |