Sha256: e66fb02b7d6c83deab0080d1948aa55d6797dfe940e34223dc8e674345fbfc68

Contents?: true

Size: 1007 Bytes

Versions: 28

Compression:

Stored size: 1007 Bytes

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Transforms
    module Transforms

      class NamedTransform < TransformRule
        Transformer = TwitterCldr::Transforms::Transformer

        class << self
          def accepts?(forward_form, backward_form)
            exists?(forward_form) && exists?(backward_form)
          end

          private

          def exists?(form)
            !form || form.null? || form.blank? || Transformer.exists?(form.transform)
          end
        end

        def apply_to(cursor)
          if forward_form
            puts forward_form.transform if $debug
            forward_form.apply_to(cursor)
          end
        end

        private

        def after_initialize
          if forward_form
            @backward_form ||= TransformPair.new(
              nil, TransformId.parse(forward_form.transform).reverse.to_s
            )
          end
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
twitter_cldr-6.12.1 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.12.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.11.5 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.11.4 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.11.3 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.11.2 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.11.1 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.11.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.10.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.9.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.8.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.7.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.6.2 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.6.1 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.6.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.5.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.4.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.3.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.2.0 lib/twitter_cldr/transforms/transforms/named_transform.rb
twitter_cldr-6.1.0 lib/twitter_cldr/transforms/transforms/named_transform.rb