Class: Regexgen::Ast::CharClass
- Inherits:
-
Object
- Object
- Regexgen::Ast::CharClass
- Defined in:
- lib/regexgen/ast.rb
Overview
Represents a character class (e.g. [0-9a-z])
Instance Attribute Summary collapse
-
#precedence ⇒ Object
readonly
Returns the value of attribute precedence.
Instance Method Summary collapse
- #char_class ⇒ Object
-
#initialize(a, b) ⇒ CharClass
constructor
A new instance of CharClass.
- #length ⇒ Object
- #single_character? ⇒ Boolean
- #single_codepoint? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(a, b) ⇒ CharClass
Returns a new instance of CharClass.
35 36 37 38 |
# File 'lib/regexgen/ast.rb', line 35 def initialize(a, b) @precedence = 1 @set = [a, b].flatten end |
Instance Attribute Details
#precedence ⇒ Object (readonly)
Returns the value of attribute precedence.
33 34 35 |
# File 'lib/regexgen/ast.rb', line 33 def precedence @precedence end |
Instance Method Details
#char_class ⇒ Object
56 57 58 |
# File 'lib/regexgen/ast.rb', line 56 def char_class @set end |
#length ⇒ Object
40 41 42 |
# File 'lib/regexgen/ast.rb', line 40 def length 1 end |
#single_character? ⇒ Boolean
44 45 46 |
# File 'lib/regexgen/ast.rb', line 44 def single_character? @set.none? { |c| c.ord > 0xffff } end |
#single_codepoint? ⇒ Boolean
48 49 50 |
# File 'lib/regexgen/ast.rb', line 48 def single_codepoint? true end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/regexgen/ast.rb', line 52 def to_s "[#{to_ranges_string}]" end |