Sha256: 829555c073adf104647807cb67f99c5b7958c782f5428ef4dd6970191cfe5f32

Contents?: true

Size: 307 Bytes

Versions: 5

Compression:

Stored size: 307 Bytes

Contents

module Iz
  class Hexadecimal
    REGEX = /^[0-9a-f]+$/i

    attr_accessor :value

    def initialize(hexadecimal)
      self.value = hexadecimal
    end

    def valid?
      !!Iz::Hexadecimal.is_hexadecimal?(value)
    end

    def self.is_hexadecimal?(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/hexadecimal.rb
iz-0.3.0 lib/iz/hexadecimal.rb
iz-0.2.1 lib/iz/hexadecimal.rb
iz-0.2.0 lib/iz/hexadecimal.rb
iz-0.1.0 lib/iz/hexadecimal.rb