Sha256: 8c50be46d5b797d7d605474ed593410b2734933d2b24ef21c602fdcbd0d0cc69

Contents?: true

Size: 1004 Bytes

Versions: 19

Compression:

Stored size: 1004 Bytes

Contents

# encoding: UTF-8

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

module TwitterCldr
  module Parsers
    class UnicodeRegexParser

      # Regex character range eg. a-z or 0-9
      # Can only exist in character classes
      class CharacterRange < Component

        attr_reader :initial, :final

        def initialize(initial, final)
          @initial = initial
          @final = final
        end

        # Unfortunately, due to the ambiguity of having both character
        # ranges and set operations in the same syntax (which both use
        # the "-" operator and square brackets), we have to treat
        # CharacterRange as both a token and an operand. This type method
        # helps it behave like a token.
        def type
          :character_range
        end

        def to_set
          TwitterCldr::Utils::RangeSet.new(
            [initial.to_set.to_full_a.first..final.to_set.to_full_a.first]
          )
        end

      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/parsers/unicode_regex/character_range.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/parsers/unicode_regex/character_range.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.2.1 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.2.0 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.1.2 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.1.1 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.1.0 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.10 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.9 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.8 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.7 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.6 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.5 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.4 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.3 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.2 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.1 lib/twitter_cldr/parsers/unicode_regex/character_range.rb
twitter_cldr-3.0.0 lib/twitter_cldr/parsers/unicode_regex/character_range.rb