Class: Herb::Warnings::Warning
- Inherits:
-
Object
- Object
- Herb::Warnings::Warning
- Defined in:
- lib/herb/warnings.rb
Overview
: type serialized_warning = { | type: String, | location: serialized_location?, | message: String | }
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
: Location?.
-
#message ⇒ Object
readonly
: String.
-
#type ⇒ Object
readonly
: String.
Instance Method Summary collapse
-
#class_name ⇒ Object
: () -> String.
-
#initialize(type, location, message) ⇒ Warning
constructor
: (String, Location, String) -> void.
-
#to_hash ⇒ Object
: () -> serialized_warning.
-
#to_json(state = nil) ⇒ Object
: (?untyped) -> String.
-
#warning_name ⇒ Object
: () -> String.
Constructor Details
#initialize(type, location, message) ⇒ Warning
: (String, Location, String) -> void
17 18 19 20 21 |
# File 'lib/herb/warnings.rb', line 17 def initialize(type, location, ) @type = type @location = location @message = end |
Instance Attribute Details
#location ⇒ Object (readonly)
: Location?
13 14 15 |
# File 'lib/herb/warnings.rb', line 13 def location @location end |
#message ⇒ Object (readonly)
: String
14 15 16 |
# File 'lib/herb/warnings.rb', line 14 def @message end |
#type ⇒ Object (readonly)
: String
12 13 14 |
# File 'lib/herb/warnings.rb', line 12 def type @type end |
Instance Method Details
#class_name ⇒ Object
: () -> String
33 34 35 |
# File 'lib/herb/warnings.rb', line 33 def class_name self.class.name || "Warning" end |
#to_hash ⇒ Object
: () -> serialized_warning
24 25 26 27 28 29 30 |
# File 'lib/herb/warnings.rb', line 24 def to_hash { type: type, location: location&.to_hash, message: , } end |
#to_json(state = nil) ⇒ Object
: (?untyped) -> String
43 44 45 |
# File 'lib/herb/warnings.rb', line 43 def to_json(state = nil) to_hash.to_json(state) end |
#warning_name ⇒ Object
: () -> String
38 39 40 |
# File 'lib/herb/warnings.rb', line 38 def warning_name class_name.split("::").last || "Warning" end |