Sha256: 9820901ddc9728f6a6c8030abe8ba1a92412c90cce9caec9f903c64123b1206a

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literal: true

class BinaryCharacteristics < Characteristics
  BLANKS = [
    0x9,
    0x20,
  ].freeze

  SEPARATORS = [
    0xA,
    0xB,
    0xC,
    0xD,
  ].freeze

  def initialize(char)
    @ord = char.ord
    @encoding = char.encoding
    @encoding_name = @encoding.name
  end

  def valid?
    true
  end

  def unicode?
    false
  end

  def assigned?
    true
  end

  def control?
    c0? || delete?
  end

  def c0?
    @ord < 0x20
  end

  def delete?
    @ord == 0x7F
  end

  def blank?
    BLANKS.include?(@ord) || SEPARATORS.include?(@ord)
  end

  def format?
    false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
characteristics-0.4.0 lib/characteristics/binary.rb