Class: Expressir::Commands::NonAsciiCharacter
- Inherits:
-
Object
- Object
- Expressir::Commands::NonAsciiCharacter
- Defined in:
- lib/expressir/commands/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.
14 15 16 17 18 19 20 21 22 |
# File 'lib/expressir/commands/validate_ascii.rb', line 14 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.
11 12 13 |
# File 'lib/expressir/commands/validate_ascii.rb', line 11 def char @char end |
#hex ⇒ Object (readonly)
Returns the value of attribute hex.
11 12 13 |
# File 'lib/expressir/commands/validate_ascii.rb', line 11 def hex @hex end |
#is_math ⇒ Object (readonly)
Returns the value of attribute is_math.
11 12 13 |
# File 'lib/expressir/commands/validate_ascii.rb', line 11 def is_math @is_math end |
#occurrences ⇒ Object (readonly)
Returns the value of attribute occurrences.
11 12 13 |
# File 'lib/expressir/commands/validate_ascii.rb', line 11 def occurrences @occurrences end |
#replacement ⇒ Object (readonly)
Returns the value of attribute replacement.
11 12 13 |
# File 'lib/expressir/commands/validate_ascii.rb', line 11 def replacement @replacement end |
#replacement_type ⇒ Object (readonly)
Returns the value of attribute replacement_type.
11 12 13 |
# File 'lib/expressir/commands/validate_ascii.rb', line 11 def replacement_type @replacement_type end |
#utf8 ⇒ Object (readonly)
Returns the value of attribute utf8.
11 12 13 |
# File 'lib/expressir/commands/validate_ascii.rb', line 11 def utf8 @utf8 end |
Instance Method Details
#add_occurrence(line_number, column, line) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/expressir/commands/validate_ascii.rb', line 24 def add_occurrence(line_number, column, line) @occurrences << { line_number: line_number, column: column, line: line, } end |
#occurrence_count ⇒ Object
36 37 38 |
# File 'lib/expressir/commands/validate_ascii.rb', line 36 def occurrence_count @occurrences.size end |
#replacement_text ⇒ Object
32 33 34 |
# File 'lib/expressir/commands/validate_ascii.rb', line 32 def replacement_text @is_math ? "AsciiMath: #{@replacement}" : "ISO 10303-11: #{@replacement}" end |
#to_h ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/expressir/commands/validate_ascii.rb', line 40 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 |