Sha256: c4436eebe6dd4e0bdf48f311d75cd8ea40b284ef10f3c8d8ccdbdb0cfe92cacc

Contents?: true

Size: 348 Bytes

Versions: 1

Compression:

Stored size: 348 Bytes

Contents

module UniversalValidators
  class MacAddressValidator
    def initialize(mac_address)
      @mac_address = mac_address.to_s
    end

    def valid?
      mac_address = @mac_address.scan(/[0-9a-f]+/i).join

      return if mac_address.length != 12

      mac_address.scan(/.{2}/).select { |pair| pair.to_i(16) > 255 }.length == 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
universal_validators-1.0.0 lib/universal_validators/mac_address_validator.rb