Sha256: 50ac9fc5af4fe957ed693c4ea2404f138f6f84cec50b54f99ad89b6d0ba40d12

Contents?: true

Size: 304 Bytes

Versions: 5

Compression:

Stored size: 304 Bytes

Contents

module Iz
  class Binary
    REGEX = /^[01]+$/

    attr_accessor :value

    def initialize(binary)
      self.value = binary
    end

    def valid?
      !!Iz::Binary.is_binary?(value)
    end

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