Sha256: c680bb3924491b906e38c2971ffa162c77e80603bf808a2cbf60b6606ee62142

Contents?: true

Size: 691 Bytes

Versions: 5

Compression:

Stored size: 691 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.hash ^ state.hash
      end

      def state
        [@traits]
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shivers-0.6.0.pre.7 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.6 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.5 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.4 lib/shivers/parts/alphanumeric.rb
shivers-0.6.0.pre.3 lib/shivers/parts/alphanumeric.rb