Class: Expressir::Commands::NonAsciiCharacter

Inherits:
Object
  • Object
show all
Defined in:
lib/expressir/commands/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.



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

#charObject (readonly)

Returns the value of attribute char.



11
12
13
# File 'lib/expressir/commands/validate_ascii.rb', line 11

def char
  @char
end

#hexObject (readonly)

Returns the value of attribute hex.



11
12
13
# File 'lib/expressir/commands/validate_ascii.rb', line 11

def hex
  @hex
end

#is_mathObject (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

#occurrencesObject (readonly)

Returns the value of attribute occurrences.



11
12
13
# File 'lib/expressir/commands/validate_ascii.rb', line 11

def occurrences
  @occurrences
end

#replacementObject (readonly)

Returns the value of attribute replacement.



11
12
13
# File 'lib/expressir/commands/validate_ascii.rb', line 11

def replacement
  @replacement
end

#replacement_typeObject (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

#utf8Object (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_countObject



36
37
38
# File 'lib/expressir/commands/validate_ascii.rb', line 36

def occurrence_count
  @occurrences.size
end

#replacement_textObject



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_hObject



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