Class: Regexp::Expression::Group::Base

Inherits:
Subexpression show all
Defined in:
lib/regexp_parser/expression/classes/group.rb

Direct Known Subclasses

Assertion::Base, Atomic, Capture, Comment, Options, Passive

Instance Attribute Summary

Attributes inherited from Subexpression

#expressions

Attributes inherited from Base

#conditional_level, #level, #options, #quantifier, #set_level, #text, #token, #ts, #type

Instance Method Summary collapse

Methods inherited from Subexpression

#<<, #[], #all?, #clone, #each, #each_expression, #each_with_index, #empty?, #first, #initialize, #insert, #last, #length, #map, #strfregexp_tree, #te, #to_h, #traverse, #ts

Methods inherited from Base

#ascii_classes?, #case_insensitive?, #clone, #coded_offset, #default_classes?, #free_spacing?, #full_length, #greedy?, #initialize, #is?, #match, #matches?, #multiline?, #offset, #one_of?, #possessive?, #quantified?, #quantify, #quantity, #reluctant?, #starts_at, #strfregexp, #terminal?, #to_h, #to_re, #type?, #unicode_classes?

Constructor Details

This class inherits a constructor from Regexp::Expression::Subexpression

Instance Method Details

#capturing?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/regexp_parser/expression/classes/group.rb', line 5

def capturing?
  [:capture, :named].include? @token
end

#comment?Boolean

Returns:

  • (Boolean)


9
# File 'lib/regexp_parser/expression/classes/group.rb', line 9

def comment?; @type == :comment end

#to_s(format = :full) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/regexp_parser/expression/classes/group.rb', line 11

def to_s(format = :full)
  s = ''

  case format
  when :base
    s << @text.dup
    s << @expressions.join
    s << ')'
  else
    s << @text.dup
    s << @expressions.join
    s << ')'
    s << @quantifier.to_s if quantified?
  end

  s
end