Class: TwitterCldr::Parsers::UnicodeRegexParser::CharacterClass

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

Overview

This is analogous to ICU’s UnicodeSet class.

Defined Under Namespace

Classes: BinaryOperator, UnaryOperator

Constant Summary collapse

GROUPING_PAIRS =
{
  close_bracket: :open_bracket
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ CharacterClass

Returns a new instance of CharacterClass.



46
47
48
# File 'lib/twitter_cldr/parsers/unicode_regex/character_class.rb', line 46

def initialize(root)
  @root = root
end

Class Method Details

.closing_typesObject



36
37
38
# File 'lib/twitter_cldr/parsers/unicode_regex/character_class.rb', line 36

def closing_types
  @closing_types ||= GROUPING_PAIRS.keys
end

.opening_type_for(type) ⇒ Object



40
41
42
# File 'lib/twitter_cldr/parsers/unicode_regex/character_class.rb', line 40

def opening_type_for(type)
  GROUPING_PAIRS[type]
end

.opening_typesObject



32
33
34
# File 'lib/twitter_cldr/parsers/unicode_regex/character_class.rb', line 32

def opening_types
  @opening_types ||= GROUPING_PAIRS.values
end

Instance Method Details

#codepointsObject



62
63
64
# File 'lib/twitter_cldr/parsers/unicode_regex/character_class.rb', line 62

def codepoints
  codepoints_from(root)
end

#negated?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/twitter_cldr/parsers/unicode_regex/character_class.rb', line 70

def negated?
  root.type == :unary_operator && root.operator == :negate
end

#to_regexp_strObject



54
55
56
# File 'lib/twitter_cldr/parsers/unicode_regex/character_class.rb', line 54

def to_regexp_str
  set_to_regex(to_set)
end

#to_sObject



66
67
68
# File 'lib/twitter_cldr/parsers/unicode_regex/character_class.rb', line 66

def to_s
  stringify(root)
end

#to_setObject



58
59
60
# File 'lib/twitter_cldr/parsers/unicode_regex/character_class.rb', line 58

def to_set
  evaluate(root)
end

#typeObject



50
51
52
# File 'lib/twitter_cldr/parsers/unicode_regex/character_class.rb', line 50

def type
  :character_class
end