Class: Cldr::Data::Plurals::Expression
- Inherits:
-
Object
- Object
- Cldr::Data::Plurals::Expression
- Defined in:
- lib/cldr/data/plurals/rules.rb
Instance Attribute Summary collapse
-
#mod ⇒ Object
readonly
Returns the value of attribute mod.
-
#negate ⇒ Object
readonly
Returns the value of attribute negate.
-
#operand ⇒ Object
readonly
Returns the value of attribute operand.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
Instance Method Summary collapse
-
#initialize(operator = nil, mod = nil, negate = nil, operand = nil) ⇒ Expression
constructor
A new instance of Expression.
- #to_ruby ⇒ Object
Constructor Details
#initialize(operator = nil, mod = nil, negate = nil, operand = nil) ⇒ Expression
Returns a new instance of Expression.
92 93 94 |
# File 'lib/cldr/data/plurals/rules.rb', line 92 def initialize(operator = nil, mod = nil, negate = nil, operand = nil) @operator, @mod, @negate, @operand = operator, mod, negate, operand end |
Instance Attribute Details
#mod ⇒ Object (readonly)
Returns the value of attribute mod.
90 91 92 |
# File 'lib/cldr/data/plurals/rules.rb', line 90 def mod @mod end |
#negate ⇒ Object (readonly)
Returns the value of attribute negate.
90 91 92 |
# File 'lib/cldr/data/plurals/rules.rb', line 90 def negate @negate end |
#operand ⇒ Object (readonly)
Returns the value of attribute operand.
90 91 92 |
# File 'lib/cldr/data/plurals/rules.rb', line 90 def operand @operand end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
90 91 92 |
# File 'lib/cldr/data/plurals/rules.rb', line 90 def operator @operator end |
Instance Method Details
#to_ruby ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/cldr/data/plurals/rules.rb', line 96 def to_ruby @ruby ||= begin op = 'n' op << " % #{@mod}" if mod case @operator when :is op + (@negate ? ' != ' : ' == ') + @operand when :in (@negate ? '!' : '') + "#{@operand}.include?(#{op})" else op end end end |