class Xeme::Message
A Xeme::Message
object represents a single error, warning, or note. It is the base class for Xeme::Message::Error, Xeme::Message::Warning, and Xeme::Message::Note. Don't instantiate Xeme::Message
directly, use Xeme#error
, Xeme#warning
, or Xeme#note
.
Each message contains at least an id. It can also have an options details hash which can be used to store misc information about the message.
The message itself can be treated like a hash to give details:
msg = xeme.error('my-error') msg['location'] = 1
Attributes
details[R]
Details about the message.
id[R]
The id of the message.
Public Class Methods
new(id, details={})
click to toggle source
Initialize a Xeme::Message
object with the id of the message. The id can be any string. The optional details
hash will be stored with the message.
# File lib/xeme.rb, line 475 def initialize(id, details={}) # $tm.hr __method__ # set id @id = id # initialize details @details = details.clone end
Public Instance Methods
to_h()
click to toggle source
Returns a hash structure of the message. This structure is used by Xeme#to_h
.
# File lib/xeme.rb, line 497 def to_h rv = {} rv['id'] = @id if @details.any? rv['details'] = @details end return rv end