Class: TwitterCldr::Transforms::Transforms::NamedTransform

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

Constant Summary collapse

Transformer =
TwitterCldr::Transforms::Transformer

Constants inherited from Rule

Rule::STRING_TYPES

Instance Attribute Summary

Attributes inherited from TransformRule

#backward_form, #forward_form

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TransformRule

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

Methods inherited from Rule

#backward?, #forward?, #invert, #is_comment?, #is_conversion_rule?, #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

Class Method Details

.accepts?(forward_form, backward_form) ⇒ Boolean

Returns:

  • (Boolean)


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

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

Instance Method Details

#apply_to(cursor) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/twitter_cldr/transforms/transforms/named_transform.rb', line 25

def apply_to(cursor)
  if forward_form
    rule_set = forward_form.to_rule_set
    cursor.set_text(rule_set.transform(cursor.text))
    cursor.reset_position
  end
end