Sha256: c2adf5278c92170000b68066e64a19a7896340e646079604f6577c7e1e4b7f84

Contents?: true

Size: 687 Bytes

Versions: 8

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

require_relative 'mixins/multivaluable'
require_relative '../value_equality'

module Shivers
  module Parts
    class Alphanumeric
      include ValueEquality
      include Mixins::Multivaluable

      def initialize(data = {})
        @traits = data[:traits] || []
      end

      def matcher
        /[a-zA-Z0-9]+/
      end

      def convert(value)
        value
      end

      def capturable?
        true
      end

      def ==(other)
        other.class == self.class && other.state == state
      end

      alias eql? ==

      def hash
        [self.class, state].hash
      end

      def state
        [@traits]
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shivers-0.6.0.pre.15 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.14 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.13 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.12 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.11 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.10 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.9 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.8 lib/shivers/parts/alphanumeric.rb