Sha256: 7241555b4ed4a4fa49af0f5c838a85e6283d6e4ab062cf5cfd1ea24c3ca7e4d1

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

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

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

  def initialize(char)
    super
    @ord = char.ord if @is_valid
  end

  def unicode?
    false
  end

  def assigned?
    true
  end

  def control?
    c0? || delete?
  end

  def c0?
    @is_valid && @ord < 0x20
  end

  def delete?
    @is_valid && @ord == 0x7F
  end

  def c1?
    false
  end

  def blank?
    @is_valid && ( 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/ascii.rb
characteristics-0.3.0 lib/characteristics/ascii.rb