Class: TwitterCldr::Transforms::Transforms::CasingTransform

Inherits:
TransformRule show all
Defined in:
lib/twitter_cldr/transforms/transforms/casing_transform.rb

Constant Summary collapse

VALID_FORMS =
%w(lower upper title)

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/casing_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/casing_transform.rb', line 27

def forward_transform
  @forward_transform
end

Class Method Details

.accepts?(forward_form, backward_form) ⇒ Boolean

Returns:

  • (Boolean)

14
15
16
# File 'lib/twitter_cldr/transforms/transforms/casing_transform.rb', line 14

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
42
# File 'lib/twitter_cldr/transforms/transforms/casing_transform.rb', line 29

def apply_to(cursor)
  if forward_transform
    case forward_transform
      when 'lower'
        apply_lower(cursor)
      when 'upper'
        apply_upper(cursor)
      when 'title'
        apply_title(cursor)
    end

    cursor.reset_position
  end
end