Exception: TermUtils::AP::ParseError
- Inherits:
-
StandardError
- Object
- StandardError
- TermUtils::AP::ParseError
- Defined in:
- lib/term_utils/ap.rb
Overview
ParseError.
Class Method Summary collapse
-
.create_message(props) ⇒ String
Creates a message based on given properties.
Instance Method Summary collapse
-
#fault ⇒ String?
Returns the faulty argument (if any).
-
#fault? ⇒ Boolean
Tests whether this one has a faulty argument.
-
#initialize(props = {}) ⇒ ParseError
constructor
Constructs a new ParseError.
-
#parameter ⇒ Symbol?
Returns the syntax parameter ID (if any).
-
#parameter? ⇒ Boolean
Tests whether this one has a syntax parameter ID.
-
#props ⇒ Hash<Symbol, Object>
Returns the properties associated to this one.
-
#short_message ⇒ String
Returns the short message (i.e. the message without properties).
Constructor Details
#initialize(props = {}) ⇒ ParseError
Constructs a new ParseError.
33 34 35 36 |
# File 'lib/term_utils/ap.rb', line 33 def initialize(props = {}) super(self.class.(props)) @props = props.dup end |
Class Method Details
.create_message(props) ⇒ String
Creates a message based on given properties.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/term_utils/ap.rb', line 77 def self.(props) props = props.dup msg = props.delete(:message) { |key| raise StandardError, "#{key} property is mandatory" } return msg if props.empty? vals = [] props.each do |key, val| vals << "#{key}: \"#{val}\"" end "#{msg} (#{vals.join(', ')})" end |
Instance Method Details
#fault ⇒ String?
Returns the faulty argument (if any).
70 71 72 |
# File 'lib/term_utils/ap.rb', line 70 def fault @props.fetch(:fault, nil) end |
#fault? ⇒ Boolean
Tests whether this one has a faulty argument.
64 65 66 |
# File 'lib/term_utils/ap.rb', line 64 def fault? @props.key?(:fault) end |
#parameter ⇒ Symbol?
Returns the syntax parameter ID (if any).
58 59 60 |
# File 'lib/term_utils/ap.rb', line 58 def parameter @props.fetch(:parameter, nil) end |
#parameter? ⇒ Boolean
Tests whether this one has a syntax parameter ID.
52 53 54 |
# File 'lib/term_utils/ap.rb', line 52 def parameter? @props.key?(:parameter) end |
#props ⇒ Hash<Symbol, Object>
Returns the properties associated to this one.
40 41 42 |
# File 'lib/term_utils/ap.rb', line 40 def props @props.dup end |
#short_message ⇒ String
Returns the short message (i.e. the message without properties).
46 47 48 |
# File 'lib/term_utils/ap.rb', line 46 def @props.fetch(:message) end |