Gettext::PluralForm::Interpreter
Inherits Gettext::PluralForm::ExpressionVisitor / Reference / Object
A interpreter that calculates the plural-form to take from syntax trees representing the plural-form expression.
Constructors
Creates an interpreter with the given expression trees from the PluralForm::Parser as input.
plural_form_scanner = Gettext::PluralForm::Scanner.new("nplurals=2; plural=(n > 1);")
expressions = Gettext::PluralForm::Parser.new(plural_form_scanner.scan).parse
interpreter = Gettext::PluralForm::Interpreter.new(expressions)
interpreter.interpret(1) # => 0
interpreter.interpret(50) # => 1