Class: TwitterCldr::Transforms::Transforms::NormalizationTransform

Inherits:
TransformRule
  • Object
show all
Defined in:
lib/twitter_cldr/transforms/transforms/normalization_transform.rb

Constant Summary

Constants inherited from Rule

Rule::STRING_TYPES

Instance Attribute Summary collapse

Attributes inherited from TransformRule

#backward_form, #forward_form

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TransformRule

#backward?, blank?, #forward?, #initialize, #invert, #is_transform_rule?, null?, parse

Methods inherited from Rule

#backward?, #forward?, #invert, #is_comment?, #is_conversion_rule?, #is_conversion_rule_set?, #is_filter_rule?, #is_transform_rule?, #is_variable?, regexp_token_string, remove_comment, replace_symbols, #token_string, token_string, token_value, #token_value

Constructor Details

This class inherits a constructor from TwitterCldr::Transforms::Transforms::TransformRule

Instance Attribute Details

#backward_transformObject (readonly)

Returns the value of attribute backward_transform.


27
28
29
# File 'lib/twitter_cldr/transforms/transforms/normalization_transform.rb', line 27

def backward_transform
  @backward_transform
end

#forward_transformObject (readonly)

Returns the value of attribute forward_transform.


27
28
29
# File 'lib/twitter_cldr/transforms/transforms/normalization_transform.rb', line 27

def forward_transform
  @forward_transform
end

Class Method Details

.accepts?(forward_form, backward_form) ⇒ Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/twitter_cldr/transforms/transforms/normalization_transform.rb', line 12

def accepts?(forward_form, backward_form)
  valid_form?(forward_form) && valid_form?(backward_form)
end

Instance Method Details

#apply_to(cursor) ⇒ Object


29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/twitter_cldr/transforms/transforms/normalization_transform.rb', line 29

def apply_to(cursor)
  if forward_transform
    puts forward_transform if $debug

    cursor.set_text(
      TwitterCldr::Normalization.normalize(
        cursor.text, using: forward_transform
      )
    )

    cursor.reset_position
  end
end