Class: HecksPlugins::JSONValidator::MessageParser
- Inherits:
-
Object
- Object
- HecksPlugins::JSONValidator::MessageParser
- Defined in:
- lib/parsers/message_parser.rb
Overview
Turn the json-schema messages into easy to understand errors for the user
Instance Attribute Summary collapse
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#fragment ⇒ Object
readonly
Returns the value of attribute fragment.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(matcher:, error:) ⇒ MessageParser
constructor
A new instance of MessageParser.
Constructor Details
#initialize(matcher:, error:) ⇒ MessageParser
Returns a new instance of MessageParser.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/parsers/message_parser.rb', line 7 def initialize(matcher:, error:) @matcher = matcher @error = error @match = error[:message].match(matcher[:regex]) @fragment = error[:fragment].gsub('#/', '') if fragment == '' @fragment = nil else @fragment = fragment.to_sym end end |
Instance Attribute Details
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
5 6 7 |
# File 'lib/parsers/message_parser.rb', line 5 def field_name @field_name end |
#fragment ⇒ Object (readonly)
Returns the value of attribute fragment.
5 6 7 |
# File 'lib/parsers/message_parser.rb', line 5 def fragment @fragment end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/parsers/message_parser.rb', line 5 def @message end |
Instance Method Details
#call ⇒ Object
20 21 22 23 |
# File 'lib/parsers/message_parser.rb', line 20 def call parse_match self end |