Class: Fiva::Message
- Inherits:
-
Object
- Object
- Fiva::Message
- Defined in:
- lib/fiva/message.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#level ⇒ Object
Returns the value of attribute level.
-
#msg ⇒ Object
Returns the value of attribute msg.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(level, msg, **data) ⇒ Message
constructor
A new instance of Message.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(level, msg, **data) ⇒ Message
Returns a new instance of Message.
5 6 7 8 9 10 |
# File 'lib/fiva/message.rb', line 5 def initialize(level, msg, **data) = DateTime.now @level = level @msg = msg @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/fiva/message.rb', line 3 def data @data end |
#level ⇒ Object
Returns the value of attribute level.
3 4 5 |
# File 'lib/fiva/message.rb', line 3 def level @level end |
#msg ⇒ Object
Returns the value of attribute msg.
3 4 5 |
# File 'lib/fiva/message.rb', line 3 def msg @msg end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/fiva/message.rb', line 3 def end |
Instance Method Details
#to_hash ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/fiva/message.rb', line 12 def to_hash { timestamp: , level: @level, msg: @msg, data: @data } end |
#to_json ⇒ Object
21 22 23 |
# File 'lib/fiva/message.rb', line 21 def to_json self.to_hash.to_json end |