Class: Treat::Workers::Inflectors::Declensors::English
- Inherits:
-
Object
- Object
- Treat::Workers::Inflectors::Declensors::English
- Defined in:
- lib/treat/workers/inflectors/declensors/english.rb
Overview
Inflection using the inflect module copied from the unmaintained ‘english’ ruby gem.
License: MIT Website: english.rubyforge.org
Constant Summary collapse
- POS =
Part of speech that can be declensed.
['noun', 'adjective', 'determiner']
Class Method Summary collapse
-
.declense(entity, options) ⇒ Object
Retrieve the declensions (singular, plural) of an english word using a class lifted from the ‘english’ ruby gem.
Class Method Details
.declense(entity, options) ⇒ Object
Retrieve the declensions (singular, plural) of an english word using a class lifted from the ‘english’ ruby gem.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/treat/workers/inflectors/declensors/english.rb', line 16 def self.declense(entity, ) cat = entity.check_has(:category) return unless POS.include?(cat) unless [:count] raise Treat::Exception, 'Must supply ' + 'option count ("singular" or "plural").' end string = entity.to_s if [:count].to_s == 'plural' Inflect.plural(string) elsif [:count].to_s == 'singular' Inflect.singular(string) end end |