Sha256: c246eb261551f770ef1dc7af32a9be2819e25e59a9210c7adc54cfac5dc0d689

Contents?: true

Size: 772 Bytes

Versions: 13

Compression:

Stored size: 772 Bytes

Contents

# frozen_string_literal: true

require 'cased/sensitive/range'

module Cased
  module Sensitive
    class String < String
      attr_reader :label
      attr_reader :string

      def initialize(string, label: nil)
        super(string)
        @label = label
      end

      def range(key:)
        Cased::Sensitive::Range.new(
          label: label,
          key: key,
          begin_offset: 0,
          end_offset: length,
        )
      end

      def matches(regex)
        offset = 0
        matches = []

        while (result = match(regex, offset))
          matches.push(result)
          offset = result.end(0)
        end

        matches
      end

      def ==(other)
        super(other) &&
          @label == other.label
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cased-ruby-0.5.2 lib/cased/sensitive/string.rb
cased-ruby-0.5.1 lib/cased/sensitive/string.rb
cased-ruby-0.5.0 lib/cased/sensitive/string.rb
cased-ruby-0.4.8 lib/cased/sensitive/string.rb
cased-ruby-0.4.7 lib/cased/sensitive/string.rb
cased-ruby-0.4.6 lib/cased/sensitive/string.rb
cased-ruby-0.4.5 lib/cased/sensitive/string.rb
cased-ruby-0.4.4 lib/cased/sensitive/string.rb
cased-ruby-0.4.3 lib/cased/sensitive/string.rb
cased-ruby-0.4.2 lib/cased/sensitive/string.rb
cased-ruby-0.4.1 lib/cased/sensitive/string.rb
cased-ruby-0.4.0 lib/cased/sensitive/string.rb
cased-ruby-0.3.3 lib/cased/sensitive/string.rb