class Arborist::Node::Ack
The inner class for the 'ack' operational property
Attributes
message[R]
The object's message, :sender, :via, :time
sender[R]
The object's message, :sender, :via, :time
time[R]
The object's message, :sender, :via, :time
via[R]
The object's message, :sender, :via, :time
Public Class Methods
from_hash( hash )
click to toggle source
Construct an instance from the values in the specified hash
.
# File lib/arborist/node/ack.rb, line 12 def self::from_hash( hash ) hash = symbolify_keys( hash ) message = hash.delete( :message ) or raise ArgumentError, "Missing required ACK message" sender = hash.delete( :sender ) or raise ArgumentError, "Missing required ACK sender" if hash[:time] hash[:time] = Time.at( hash[:time] ) if hash[:time].is_a?( Numeric ) hash[:time] = Time.parse( hash[:time] ) unless hash[:time].is_a?( Time ) end return new( message, sender, **hash ) end
new( message, sender, via: nil, time: nil )
click to toggle source
Create a new acknowledgement
# File lib/arborist/node/ack.rb, line 28 def initialize( message, sender, via: nil, time: nil ) time ||= Time.now @message = message @sender = sender @via = via @time = time.to_time end
Public Instance Methods
==( other )
click to toggle source
Returns true if the other
object is an Ack
with the same values.
# File lib/arborist/node/ack.rb, line 64 def ==( other ) return other.is_a?( self.class ) && self.to_h == other.to_h end
description()
click to toggle source
Return a string description of the acknowledgement for logging and inspection.
# File lib/arborist/node/ack.rb, line 43 def description return "by %s%s -- %s" % [ self.sender, self.via ? " via #{self.via}" : '', self.message ] end
to_h( * )
click to toggle source
Return the Ack
as a Hash.
# File lib/arborist/node/ack.rb, line 53 def to_h( * ) return { message: self.message, sender: self.sender, via: self.via, time: self.time.iso8601, } end