Class: IRC::Models::Packet
- Inherits:
-
Object
- Object
- IRC::Models::Packet
- Defined in:
- lib/irc/models/packet.rb
Instance Attribute Summary collapse
-
#bot ⇒ Object
readonly
Returns the value of attribute bot.
-
#description ⇒ Object
Returns the value of attribute description.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#number_of_downloads ⇒ Object
Returns the value of attribute number_of_downloads.
-
#size_in_bytes ⇒ Object
Returns the value of attribute size_in_bytes.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#eql?(other) ⇒ Boolean
Returns true if the other Packet object is equal to the current.
- #hash ⇒ Object
-
#initialize(attributes) ⇒ Packet
constructor
A new instance of Packet.
- #key ⇒ Object
- #merge(other) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Packet
Returns a new instance of Packet.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/irc/models/packet.rb', line 41 def initialize(attributes) raise ArgumentError.new("Can't create a new packet. The :bot attribute is missing.") if attributes[:bot] == nil @bot = attributes[:bot] raise ArgumentError.new("Can't create a new packet. The :number attribute is missing.") if attributes[:number] == nil @number = attributes[:number] self.description = attributes[:description] self.size_in_bytes = attributes[:size_in_bytes] self.number_of_downloads = attributes[:number_of_downloads] end |
Instance Attribute Details
#bot ⇒ Object (readonly)
Returns the value of attribute bot.
34 35 36 |
# File 'lib/irc/models/packet.rb', line 34 def bot @bot end |
#description ⇒ Object
Returns the value of attribute description.
37 38 39 |
# File 'lib/irc/models/packet.rb', line 37 def description @description end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
35 36 37 |
# File 'lib/irc/models/packet.rb', line 35 def number @number end |
#number_of_downloads ⇒ Object
Returns the value of attribute number_of_downloads.
39 40 41 |
# File 'lib/irc/models/packet.rb', line 39 def number_of_downloads @number_of_downloads end |
#size_in_bytes ⇒ Object
Returns the value of attribute size_in_bytes.
38 39 40 |
# File 'lib/irc/models/packet.rb', line 38 def size_in_bytes @size_in_bytes end |
Instance Method Details
#==(other) ⇒ Object
63 64 65 |
# File 'lib/irc/models/packet.rb', line 63 def ==(other) return eql?(other) end |
#eql?(other) ⇒ Boolean
Returns true if the other Packet object is equal to the current.
68 69 70 |
# File 'lib/irc/models/packet.rb', line 68 def eql?(other) return other.instance_of?(Packet) && bot == other.bot && number == other.number && description == other.description end |
#hash ⇒ Object
72 73 74 |
# File 'lib/irc/models/packet.rb', line 72 def hash return key.hash end |
#key ⇒ Object
76 77 78 |
# File 'lib/irc/models/packet.rb', line 76 def key return "#{bot.network.name.strip}|#{bot.nick.strip}|#{number.to_s}".downcase end |
#merge(other) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/irc/models/packet.rb', line 55 def merge(other) # @bot = other.bot @number = other.number self.description = other.description self.size_in_bytes = other.size_in_bytes self.number_of_downloads = other.number_of_downloads end |