Class: TwitterCldr::Parsers::UnicodeRegexParser::CharacterSet

Inherits:
Component
  • Object
show all
Includes:
Shared
Defined in:
lib/twitter_cldr/parsers/unicode_regex/character_set.rb

Overview

Can exist inside and outside of character classes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ CharacterSet

Returns a new instance of CharacterSet.



17
18
19
20
21
22
23
# 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

Instance Attribute Details

#property_nameObject (readonly)

Returns the value of attribute property_name.



15
16
17
# File 'lib/twitter_cldr/parsers/unicode_regex/character_set.rb', line 15

def property_name
  @property_name
end

#property_valueObject (readonly)

Returns the value of attribute property_value.



15
16
17
# File 'lib/twitter_cldr/parsers/unicode_regex/character_set.rb', line 15

def property_value
  @property_value
end

Instance Method Details

#to_regexp_strObject



25
26
27
# File 'lib/twitter_cldr/parsers/unicode_regex/character_set.rb', line 25

def to_regexp_str
  set_to_regex(to_set)
end

#to_sObject



35
36
37
38
39
40
41
# 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_setObject



29
30
31
32
33
# File 'lib/twitter_cldr/parsers/unicode_regex/character_set.rb', line 29

def to_set
  codepoints.subtract(
    TwitterCldr::Shared::UnicodeRegex.invalid_regexp_chars
  )
end