Class: SvgConform::Errors::Base
- Inherits:
-
Object
- Object
- SvgConform::Errors::Base
- Defined in:
- lib/svg_conform/errors/base.rb
Overview
Base class for all SvgConform error types
Provides common interface for error and notice objects used during validation.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#column ⇒ Integer?
Get the column number of the error.
-
#element_name ⇒ String?
Get the element name of the error.
-
#initialize(type:, node:, message:) ⇒ Base
constructor
Initialize a new error/notice.
-
#line ⇒ Integer?
Get the line number of the error.
-
#to_h ⇒ Hash
Convert error to hash representation.
Constructor Details
#initialize(type:, node:, message:) ⇒ Base
Initialize a new error/notice
17 18 19 20 21 |
# File 'lib/svg_conform/errors/base.rb', line 17 def initialize(type:, node:, message:) @type = type @node = node @message = end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
10 11 12 |
# File 'lib/svg_conform/errors/base.rb', line 10 def @message end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
10 11 12 |
# File 'lib/svg_conform/errors/base.rb', line 10 def node @node end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/svg_conform/errors/base.rb', line 10 def type @type end |
Instance Method Details
#column ⇒ Integer?
Get the column number of the error
33 34 35 |
# File 'lib/svg_conform/errors/base.rb', line 33 def column @node.respond_to?(:column) ? @node.column : nil end |
#element_name ⇒ String?
Get the element name of the error
40 41 42 |
# File 'lib/svg_conform/errors/base.rb', line 40 def element_name @node.respond_to?(:name) ? @node.name : nil end |
#line ⇒ Integer?
Get the line number of the error
26 27 28 |
# File 'lib/svg_conform/errors/base.rb', line 26 def line @node.respond_to?(:line) ? @node.line : nil end |
#to_h ⇒ Hash
Convert error to hash representation
47 48 49 50 51 52 53 54 55 |
# File 'lib/svg_conform/errors/base.rb', line 47 def to_h { type: @type, message: @message, line: line, column: column, element: element_name, } end |