class TwitterCldr::Parsers::UnicodeRegexParser::CharacterSet
Can exist inside and outside of character classes
Attributes
property_name[R]
property_value[R]
Public Class Methods
new(text)
click to toggle source
# File lib/twitter_cldr/parsers/unicode_regex/character_set.rb, line 17 def initialize(text) if (name_parts = text.split("=")).size == 2 @property_name, @property_value = name_parts else @property_value = text end end
Public Instance Methods
to_regexp_str()
click to toggle source
# File lib/twitter_cldr/parsers/unicode_regex/character_set.rb, line 25 def to_regexp_str set_to_regex(to_set) end
to_s()
click to toggle source
# File lib/twitter_cldr/parsers/unicode_regex/character_set.rb, line 35 def to_s if property_value "[:#{property_name}=#{property_value}:]" else "[:#{property_name}:]" end end
to_set()
click to toggle source
# File lib/twitter_cldr/parsers/unicode_regex/character_set.rb, line 29 def to_set codepoints.subtract( TwitterCldr::Shared::UnicodeRegex.invalid_regexp_chars ) end
type()
click to toggle source
# File lib/twitter_cldr/parsers/unicode_regex/character_set.rb, line 43 def type :character_set end
Private Instance Methods
codepoints()
click to toggle source
# File lib/twitter_cldr/parsers/unicode_regex/character_set.rb, line 49 def codepoints code_points = CodePoint.code_points_for_property( *normalized_property ) if code_points.empty? raise UnicodeRegexParserError, "Couldn't find property '#{property_name}' containing "\ "property value '#{property_value}'" end code_points end
normalized_property()
click to toggle source
# File lib/twitter_cldr/parsers/unicode_regex/character_set.rb, line 65 def normalized_property property_value_candidates.each do |property_value| prop_name, prop_value = normalized_property_name( property_value, property_name_candidates ) if prop_name return [prop_name, prop_value] end end [nil, nil] end
normalized_property_name(property_value, property_name_candidates)
click to toggle source
# File lib/twitter_cldr/parsers/unicode_regex/character_set.rb, line 79 def normalized_property_name(property_value, property_name_candidates) property_name_candidates.each do |property_name| prop_name, prop_value = CodePoint.properties.normalize( property_name, property_value ) if prop_name return [prop_name, prop_value] end end [nil, nil] end
property_name_candidates()
click to toggle source
# File lib/twitter_cldr/parsers/unicode_regex/character_set.rb, line 93 def property_name_candidates if property_name [property_name] else [property_value, 'General_Category', 'Script'] end end
property_value_candidates()
click to toggle source
# File lib/twitter_cldr/parsers/unicode_regex/character_set.rb, line 101 def property_value_candidates if property_name && property_value [property_value] else [property_value, nil].uniq end end