Sha256: 0485c6e54bcafcafd05f6caf658ec3e1c1662f8ea4130a9f5ec744594341db53

Contents?: true

Size: 957 Bytes

Versions: 1

Compression:

Stored size: 957 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
            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

1 entries across 1 versions & 1 rubygems

Version Path
twitter_cldr-6.13.0 lib/twitter_cldr/transforms/transforms/named_transform.rb