Class: TwitterCldr::Formatters::Rbnf::RuleSet
- Inherits:
-
Struct
- Object
- Struct
- TwitterCldr::Formatters::Rbnf::RuleSet
- Defined in:
- lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb
Instance Attribute Summary collapse
-
#access ⇒ Object
Returns the value of attribute access.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rules ⇒ Object
Returns the value of attribute rules.
Instance Method Summary collapse
- #each_numeric_rule ⇒ Object
- #improper_fraction_rule ⇒ Object
- #master_rule ⇒ Object
- #negative_rule ⇒ Object
- #previous_rule_for(rule) ⇒ Object
- #private? ⇒ Boolean
- #proper_fraction_rule ⇒ Object
- #public? ⇒ Boolean
-
#rule_for(number, fractional = false) ⇒ Object
fractional: i.e.
- #rule_for_value(base_value) ⇒ Object
Instance Attribute Details
#access ⇒ Object
Returns the value of attribute access
12 13 14 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 12 def access @access end |
#name ⇒ Object
Returns the value of attribute name
12 13 14 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 12 def name @name end |
#rules ⇒ Object
Returns the value of attribute rules
12 13 14 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 12 def rules @rules end |
Instance Method Details
#each_numeric_rule ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 49 def each_numeric_rule if block_given? search_start_index.upto(rules.size - 1) do |i| yield rules[i] end else to_enum(:each_numeric_rule) end end |
#improper_fraction_rule ⇒ Object
29 30 31 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 29 def improper_fraction_rule rule_for_value(Rule::IMPROPER_FRACTION) end |
#master_rule ⇒ Object
25 26 27 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 25 def master_rule rule_for_value(Rule::MASTER) end |
#negative_rule ⇒ Object
37 38 39 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 37 def negative_rule rule_for_value(Rule::NEGATIVE) end |
#previous_rule_for(rule) ⇒ Object
19 20 21 22 23 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 19 def previous_rule_for(rule) if idx = rule_index_for(rule.base_value) rules[idx - 1] if idx > 0 end end |
#private? ⇒ Boolean
41 42 43 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 41 def private? access == "private" end |
#proper_fraction_rule ⇒ Object
33 34 35 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 33 def proper_fraction_rule rule_for_value(Rule::PROPER_FRACTION) end |
#public? ⇒ Boolean
45 46 47 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 45 def public? access == "public" end |
#rule_for(number, fractional = false) ⇒ Object
fractional: i.e. whether or not to consider the rule set a “fractional” rule set (special rules apply)
60 61 62 63 64 65 66 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 60 def rule_for(number, fractional = false) if fractional fractional_rule_for(number) else normal_rule_for(number) end end |
#rule_for_value(base_value) ⇒ Object
13 14 15 16 17 |
# File 'lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb', line 13 def rule_for_value(base_value) if idx = rule_index_for(base_value) rules[idx] end end |