Sha256: ab29f9492064c50c39eddda14f3581b38838fd667dcf84633368fffa730cab5d

Contents?: true

Size: 779 Bytes

Versions: 30

Compression:

Stored size: 779 Bytes

Contents

module Regexp::Expression
  class Quantifier
    MODES = [:greedy, :possessive, :reluctant]

    attr_reader :token, :text, :min, :max, :mode

    def initialize(token, text, min, max, mode)
      @token = token
      @text  = text
      @mode  = mode
      @min   = min
      @max   = max
    end

    def initialize_clone(orig)
      @text = orig.text.dup
      super
    end

    def to_s
      text.dup
    end
    alias :to_str :to_s

    def to_h
      {
        token: token,
        text:  text,
        mode:  mode,
        min:   min,
        max:   max,
      }
    end

    MODES.each do |mode|
      class_eval <<-RUBY, __FILE__, __LINE__ + 1
        def #{mode}?
          mode.equal?(:#{mode})
        end
      RUBY
    end
    alias :lazy? :reluctant?
  end
end

Version data entries

30 entries across 25 versions & 6 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/regexp_parser-1.7.0/lib/regexp_parser/expression/quantifier.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/regexp_parser-1.6.0/lib/regexp_parser/expression/quantifier.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/regexp_parser-1.7.0/lib/regexp_parser/expression/quantifier.rb
regexp_parser-1.7.0 lib/regexp_parser/expression/quantifier.rb
tdiary-5.1.0 vendor/bundle/gems/regexp_parser-1.6.0/lib/regexp_parser/expression/quantifier.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/regexp_parser-1.6.0/lib/regexp_parser/expression/quantifier.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/regexp_parser-1.6.0/lib/regexp_parser/expression/quantifier.rb
regexp_parser-1.6.0 lib/regexp_parser/expression/quantifier.rb
regexp_parser-1.5.1 lib/regexp_parser/expression/quantifier.rb
regexp_parser-1.5.0 lib/regexp_parser/expression/quantifier.rb