Class: BinaryCharacteristics

Inherits:
Characteristics show all
Defined in:
lib/characteristics/binary.rb

Constant Summary collapse

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

Constants inherited from Characteristics

Characteristics::VERSION

Instance Attribute Summary

Attributes inherited from Characteristics

#encoding

Instance Method Summary collapse

Methods inherited from Characteristics

create, create_for_type, type_from_encoding_name, #unicode?

Constructor Details

#initialize(char) ⇒ BinaryCharacteristics

Returns a new instance of BinaryCharacteristics.



14
15
16
17
18
# File 'lib/characteristics/binary.rb', line 14

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

Instance Method Details

#assigned?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/characteristics/binary.rb', line 24

def assigned?
  true
end

#blank?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/characteristics/binary.rb', line 40

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

#c0?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/characteristics/binary.rb', line 32

def c0?
  @ord < 0x20
end

#control?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/characteristics/binary.rb', line 28

def control?
  c0? || delete?
end

#delete?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/characteristics/binary.rb', line 36

def delete?
  @ord == 0x7F
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/characteristics/binary.rb', line 20

def valid?
  true
end