Sha256: c5775fc546350df8eb7b48be4c48dc0951ed624ab19a4cb1dd21668a2160d4a0

Contents?: true

Size: 584 Bytes

Versions: 2

Compression:

Stored size: 584 Bytes

Contents

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

2 entries across 2 versions & 1 rubygems

Version Path
characteristics-0.3.1 lib/characteristics/binary.rb
characteristics-0.3.0 lib/characteristics/binary.rb