Sha256: 038146ed705356805189109fb54ddbc2bc4e3aebd51cdc55899587c40c73232e

Contents?: true

Size: 1.12 KB

Versions: 113

Compression:

Stored size: 1.12 KB

Contents

module Regexp::Expression
  module Shared
    # default implementation
    def parts
      [text.dup]
    end

    private

    def intersperse(expressions, separator)
      expressions.flat_map { |exp| [exp, separator] }.slice(0...-1)
    end
  end

  CharacterSet.class_eval            { def parts; ["#{text}#{'^' if negated?}", *expressions, ']']        end }
  CharacterSet::Range.class_eval     { def parts; intersperse(expressions, text.dup)                      end }
  Conditional::Expression.class_eval { def parts; [text.dup, condition, *intersperse(branches, '|'), ')'] end }
  Group::Base.class_eval             { def parts; [text.dup, *expressions, ')']                           end }
  Group::Passive.class_eval          { def parts; implicit? ? expressions : super                         end }
  Group::Comment.class_eval          { def parts; [text.dup]                                              end }
  Subexpression.class_eval           { def parts; expressions                                             end }
  SequenceOperation.class_eval       { def parts; intersperse(expressions, text.dup)                      end }
end

Version data entries

113 entries across 112 versions & 16 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/regexp_parser-2.9.2/lib/regexp_parser/expression/methods/parts.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/regexp_parser-2.9.2/lib/regexp_parser/expression/methods/parts.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.2/lib/regexp_parser/expression/methods/parts.rb
regexp_parser-2.10.0 lib/regexp_parser/expression/methods/parts.rb
regexp_parser-2.9.3 lib/regexp_parser/expression/methods/parts.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.2/lib/regexp_parser/expression/methods/parts.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/regexp_parser-2.9.2/lib/regexp_parser/expression/methods/parts.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.8.2/lib/regexp_parser/expression/methods/parts.rb
bison-0.1.0 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/parts.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/parts.rb
study_line-0.2.7 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/parts.rb
study_line-0.2.6 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/parts.rb
study_line-0.2.5 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/parts.rb
study_line-0.2.4 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/parts.rb
study_line-0.2.3 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/parts.rb
study_line-0.2.2 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/parts.rb
study_line-0.2.1 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/parts.rb
study_line-0.2.0 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/parts.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.8.2/lib/regexp_parser/expression/methods/parts.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/regexp_parser-2.8.2/lib/regexp_parser/expression/methods/parts.rb