Class: Ax25::ImmutableMessage

Inherits:
Object
  • Object
show all
Includes:
Message
Defined in:
lib/ax25/frame/immutable_message.rb

Direct Known Subclasses

ImmutableFrame

Instance Attribute Summary

Attributes included from Message

#destination, #payload, #source

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



70
71
72
# File 'lib/ax25/frame/immutable_message.rb', line 70

def ==(other)
  return self.path_agnostic_equality? other
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/ax25/frame/immutable_message.rb', line 75

def eql?(other)
  self.path_agnostic_eql? other
end

#hashObject



80
81
82
# File 'lib/ax25/frame/immutable_message.rb', line 80

def hash
  return self.path_agnostic_hash
end

#path_agnostic_eql?(other) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


45
46
47
48
49
# File 'lib/ax25/frame/immutable_message.rb', line 45

def path_agnostic_eql?(other)
  raise ArgumentError.new("The argument must be either an ImmutableMessage or a PathAgnosticFrame") if not ((other.instance_of? Ax25::ImmutableMessage) || (other.instance_of? Ax25::PathAgnosticImmutableFrame))

  return self.path_agnostic_equality? other
end

#path_agnostic_equality?(other) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ax25/frame/immutable_message.rb', line 52

def path_agnostic_equality?(other)
  return false if (not other.respond_to? :source) ||
                  (not other.respond_to? :destination) ||
                  (not other.respond_to? :payload)

  if (self.source.eql? other.source) && (self.destination.eql? other.destination) && (self.payload.eql? other.payload)
     return true
  else
    return false
  end
end

#path_agnostic_hashObject



65
66
67
# File 'lib/ax25/frame/immutable_message.rb', line 65

def path_agnostic_hash
  return [self.source, self.destination, self.payload].hash
end