Class: TwitterCldr::Transforms::FilteredRuleSet
- Inherits:
-
Object
- Object
- TwitterCldr::Transforms::FilteredRuleSet
- Defined in:
- lib/twitter_cldr/transforms/filtered_rule_set.rb
Instance Attribute Summary collapse
-
#filter_rule ⇒ Object
readonly
Returns the value of attribute filter_rule.
-
#transform_id ⇒ Object
readonly
Returns the value of attribute transform_id.
Instance Method Summary collapse
- #backward? ⇒ Boolean
- #foward? ⇒ Boolean
-
#initialize(filter_rule, transform_id) ⇒ FilteredRuleSet
constructor
A new instance of FilteredRuleSet.
- #invert ⇒ Object
- #is_conversion_rule? ⇒ Boolean
- #is_filter_rule? ⇒ Boolean
- #is_transform_rule? ⇒ Boolean
- #rule_set ⇒ Object
- #transform(text) ⇒ Object
Constructor Details
#initialize(filter_rule, transform_id) ⇒ FilteredRuleSet
Returns a new instance of FilteredRuleSet.
15 16 17 18 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 15 def initialize(filter_rule, transform_id) @filter_rule = filter_rule @transform_id = transform_id end |
Instance Attribute Details
#filter_rule ⇒ Object (readonly)
Returns the value of attribute filter_rule.
13 14 15 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 13 def filter_rule @filter_rule end |
#transform_id ⇒ Object (readonly)
Returns the value of attribute transform_id.
13 14 15 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 13 def transform_id @transform_id end |
Instance Method Details
#backward? ⇒ Boolean
24 25 26 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 24 def backward? false end |
#foward? ⇒ Boolean
20 21 22 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 20 def foward? true end |
#invert ⇒ Object
40 41 42 43 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 40 def invert raise NotInvertibleError, "cannot invert this #{self.class.name}" end |
#is_conversion_rule? ⇒ Boolean
36 37 38 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 36 def is_conversion_rule? false end |
#is_filter_rule? ⇒ Boolean
28 29 30 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 28 def is_filter_rule? false end |
#is_transform_rule? ⇒ Boolean
32 33 34 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 32 def is_transform_rule? false end |
#rule_set ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 49 def rule_set @rule_set ||= begin rs = Transformer.get(transform_id) # replace any existing filters in all conversion rules and build # a new rule set new_rules = rs.rules.map do |rule| next rule unless rule.is_conversion_rule_set? ConversionRuleSet.new(filter_rule, nil, rule.rules) end RuleSet.new(new_rules, transform_id) end end |
#transform(text) ⇒ Object
45 46 47 |
# File 'lib/twitter_cldr/transforms/filtered_rule_set.rb', line 45 def transform(text) rule_set.transform(text) end |