Class: Suma::Cli::NonAsciiCharacter
- Inherits:
-
Object
- Object
- Suma::Cli::NonAsciiCharacter
- Defined in:
- lib/suma/cli/validate_ascii.rb
Overview
Represents a non-ASCII character with its details and replacement
Instance Attribute Summary collapse
-
#char ⇒ Object
readonly
Returns the value of attribute char.
-
#hex ⇒ Object
readonly
Returns the value of attribute hex.
-
#is_math ⇒ Object
readonly
Returns the value of attribute is_math.
-
#occurrences ⇒ Object
readonly
Returns the value of attribute occurrences.
-
#replacement ⇒ Object
readonly
Returns the value of attribute replacement.
-
#replacement_type ⇒ Object
readonly
Returns the value of attribute replacement_type.
-
#utf8 ⇒ Object
readonly
Returns the value of attribute utf8.
Instance Method Summary collapse
- #add_occurrence(line_number, column, line) ⇒ Object
-
#initialize(char, hex, utf8, is_math, replacement, replacement_type) ⇒ NonAsciiCharacter
constructor
A new instance of NonAsciiCharacter.
- #occurrence_count ⇒ Object
- #replacement_text ⇒ Object
- #to_h ⇒ Object
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
#char ⇒ Object (readonly)
Returns the value of attribute char.
14 15 16 |
# File 'lib/suma/cli/validate_ascii.rb', line 14 def char @char end |
#hex ⇒ Object (readonly)
Returns the value of attribute hex.
14 15 16 |
# File 'lib/suma/cli/validate_ascii.rb', line 14 def hex @hex end |
#is_math ⇒ Object (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 |
#occurrences ⇒ Object (readonly)
Returns the value of attribute occurrences.
14 15 16 |
# File 'lib/suma/cli/validate_ascii.rb', line 14 def occurrences @occurrences end |
#replacement ⇒ Object (readonly)
Returns the value of attribute replacement.
14 15 16 |
# File 'lib/suma/cli/validate_ascii.rb', line 14 def replacement @replacement end |
#replacement_type ⇒ Object (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 |
#utf8 ⇒ Object (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_count ⇒ Object
39 40 41 |
# File 'lib/suma/cli/validate_ascii.rb', line 39 def occurrence_count @occurrences.size end |
#replacement_text ⇒ Object
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_h ⇒ Object
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 |