Sha256: 8776c57bf9e732706243f711bde7b9a9571fdb9a5b097d9bd3dadd606c1a5481

Contents?: true

Size: 345 Bytes

Versions: 5

Compression:

Stored size: 345 Bytes

Contents

module Iz
  class Alphanumeric
    REGEX = /^[a-z0-9]+$/i

    attr_accessor :value

    def initialize(alphanumeric)
      self.value = alphanumeric
    end

    def valid?
      !!Iz::Alphanumeric.is_alphanumeric?(value)
    end

    def self.is_alphanumeric?(value)
      return false unless value
      value.to_s =~ REGEX
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
iz-0.3.1 lib/iz/alphanumeric.rb
iz-0.3.0 lib/iz/alphanumeric.rb
iz-0.2.1 lib/iz/alphanumeric.rb
iz-0.2.0 lib/iz/alphanumeric.rb
iz-0.1.0 lib/iz/alphanumeric.rb