Class: Suma::Cli::NonAsciiCharacter

Inherits:
Object
  • Object
show all
Defined in:
lib/suma/cli/validate_ascii.rb

Overview

Represents a non-ASCII character with its details and replacement

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(char, hex, utf8, is_math, replacement, replacement_type) ⇒ NonAsciiCharacter

Returns a new instance of NonAsciiCharacter.



17
18
19
20
21
22
23
24
25
# File 'lib/suma/cli/validate_ascii.rb', line 17

def initialize(char, hex, utf8, is_math, replacement, replacement_type)
  @char = char
  @hex = hex
  @utf8 = utf8
  @is_math = is_math
  @replacement = replacement
  @replacement_type = replacement_type
  @occurrences = []
end

Instance Attribute Details

#charObject (readonly)

Returns the value of attribute char.



14
15
16
# File 'lib/suma/cli/validate_ascii.rb', line 14

def char
  @char
end

#hexObject (readonly)

Returns the value of attribute hex.



14
15
16
# File 'lib/suma/cli/validate_ascii.rb', line 14

def hex
  @hex
end

#is_mathObject (readonly)

Returns the value of attribute is_math.



14
15
16
# File 'lib/suma/cli/validate_ascii.rb', line 14

def is_math
  @is_math
end

#occurrencesObject (readonly)

Returns the value of attribute occurrences.



14
15
16
# File 'lib/suma/cli/validate_ascii.rb', line 14

def occurrences
  @occurrences
end

#replacementObject (readonly)

Returns the value of attribute replacement.



14
15
16
# File 'lib/suma/cli/validate_ascii.rb', line 14

def replacement
  @replacement
end

#replacement_typeObject (readonly)

Returns the value of attribute replacement_type.



14
15
16
# File 'lib/suma/cli/validate_ascii.rb', line 14

def replacement_type
  @replacement_type
end

#utf8Object (readonly)

Returns the value of attribute utf8.



14
15
16
# File 'lib/suma/cli/validate_ascii.rb', line 14

def utf8
  @utf8
end

Instance Method Details

#add_occurrence(line_number, column, line) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/suma/cli/validate_ascii.rb', line 27

def add_occurrence(line_number, column, line)
  @occurrences << {
    line_number: line_number,
    column: column,
    line: line,
  }
end

#occurrence_countObject



39
40
41
# File 'lib/suma/cli/validate_ascii.rb', line 39

def occurrence_count
  @occurrences.size
end

#replacement_textObject



35
36
37
# File 'lib/suma/cli/validate_ascii.rb', line 35

def replacement_text
  @is_math ? "AsciiMath: #{@replacement}" : "ISO 10303-11: #{@replacement}"
end

#to_hObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/suma/cli/validate_ascii.rb', line 43

def to_h
  {
    character: @char,
    hex: @hex,
    utf8: @utf8,
    is_math: @is_math,
    replacement_type: @replacement_type,
    replacement: @replacement,
    occurrence_count: occurrence_count,
    occurrences: @occurrences,
  }
end