lib/zenlish/inflect/inflection_table.rb in zenlish-0.2.00 vs lib/zenlish/inflect/inflection_table.rb in zenlish-0.2.01
- old
+ new
@@ -19,15 +19,20 @@
def add_rule(aRule)
@rules << aRule
end
def inflect(aLexeme, theConstraints)
+ constraints = if theConstraints.nil? || theConstraints.empty?
+ Array.new(headings.size) { |_i| nil }
+ else
+ theConstraints
+ end
err_msg = "Table has #{headings.size} headings."
- raise StandardError, err_msg if theConstraints.size != headings.size
+ raise StandardError, err_msg if constraints.size != headings.size
actuals = []
headings.each_with_index do |hd, idx|
- if theConstraints[idx]
- actuals << theConstraints[idx]
+ if constraints[idx]
+ actuals << constraints[idx]
else
actuals << hd.evaluate_for(aLexeme)
end
end
# Hit policy: first
\ No newline at end of file