Class: AsciiCharacteristics

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

Constant Summary collapse

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

Constants inherited from Characteristics

Characteristics::UNICODE_VERSION, Characteristics::VERSION

Instance Attribute Summary

Attributes inherited from Characteristics

#encoding

Instance Method Summary collapse

Methods inherited from Characteristics

create, create_for_type, #docomo?, #kddi?, #softbank?, type_from_encoding_name

Constructor Details

#initialize(char) ⇒ AsciiCharacteristics

Returns a new instance of AsciiCharacteristics.



16
17
18
19
# File 'lib/characteristics/ascii.rb', line 16

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

Instance Method Details

#assigned?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/characteristics/ascii.rb', line 29

def assigned?
  true
end

#bidi_control?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/characteristics/ascii.rb', line 61

def bidi_control?
  false
end

#blank?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/characteristics/ascii.rb', line 49

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

#c0?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/characteristics/ascii.rb', line 37

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

#c1?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/characteristics/ascii.rb', line 45

def c1?
  false
end

#control?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/characteristics/ascii.rb', line 33

def control?
  c0? || delete?
end

#delete?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/characteristics/ascii.rb', line 41

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

#format?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/characteristics/ascii.rb', line 57

def format?
  false
end

#separator?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/characteristics/ascii.rb', line 53

def separator?
  SEPARATORS.include?(@ord)
end

#unicode?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/characteristics/ascii.rb', line 25

def unicode?
  false
end

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/characteristics/ascii.rb', line 21

def valid?
  @is_valid && !(@encoding_name != "US-ASCII" && @ord >= 0x80)
end