Class: IRC::Models::Bot
Instance Attribute Summary collapse
-
#bandwidth_capacity ⇒ Object
Returns the value of attribute bandwidth_capacity.
-
#bandwidth_current ⇒ Object
Returns the value of attribute bandwidth_current.
-
#bandwidth_record ⇒ Object
Returns the value of attribute bandwidth_record.
-
#bot_type ⇒ Object
Returns the value of attribute bot_type.
-
#command_details ⇒ Object
Returns the value of attribute command_details.
-
#command_list ⇒ Object
Returns the value of attribute command_list.
-
#command_request ⇒ Object
Returns the value of attribute command_request.
-
#queue_position ⇒ Object
Returns the value of attribute queue_position.
-
#queue_size ⇒ Object
Returns the value of attribute queue_size.
-
#slots_open ⇒ Object
Returns the value of attribute slots_open.
-
#slots_total ⇒ Object
Returns the value of attribute slots_total.
-
#transfer_max ⇒ Object
Returns the value of attribute transfer_max.
-
#transfer_min ⇒ Object
Returns the value of attribute transfer_min.
-
#transfer_record ⇒ Object
Returns the value of attribute transfer_record.
Attributes inherited from User
#hostname, #login, #network, #nick, #realname
Instance Method Summary collapse
- #add_channel(channel) ⇒ Object
- #channels ⇒ Object
- #create_packet(number, description, size_in_bytes = nil, number_of_downloads = nil) ⇒ Object
-
#initialize(attributes) ⇒ Bot
constructor
A new instance of Bot.
- #merge(other) ⇒ Object
- #packet(number) ⇒ Object
- #packets ⇒ Object
- #update_packet(number, description, size_in_bytes = nil, number_of_downloads = nil) ⇒ Object
Methods inherited from User
#==, #eql?, #hash, #key, #remove_channel, #to_s, #to_str
Constructor Details
#initialize(attributes) ⇒ Bot
Returns a new instance of Bot.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/irc/models/bot.rb', line 55 def initialize(attributes) super(attributes) self.bot_type = attributes[:bot_type] self.bandwidth_capacity = attributes[:bandwidth_capacity] self.bandwidth_current = attributes[:bandwidth_current] self.bandwidth_record = attributes[:bandwidth_record] self.command_details = attributes[:command_details] self.command_list = attributes[:command_list] self.command_request = attributes[:command_request] self.queue_position = attributes[:queue_position] self.queue_size = attributes[:queue_size] self.slots_open = attributes[:slots_open] self.slots_total = attributes[:slots_total] self.transfer_max = attributes[:transfer_max] self.transfer_min = attributes[:transfer_min] self.transfer_record = attributes[:transfer_record] @channels = Hash.new @packets = Array.new end |
Instance Attribute Details
#bandwidth_capacity ⇒ Object
Returns the value of attribute bandwidth_capacity.
37 38 39 |
# File 'lib/irc/models/bot.rb', line 37 def bandwidth_capacity @bandwidth_capacity end |
#bandwidth_current ⇒ Object
Returns the value of attribute bandwidth_current.
38 39 40 |
# File 'lib/irc/models/bot.rb', line 38 def bandwidth_current @bandwidth_current end |
#bandwidth_record ⇒ Object
Returns the value of attribute bandwidth_record.
39 40 41 |
# File 'lib/irc/models/bot.rb', line 39 def bandwidth_record @bandwidth_record end |
#bot_type ⇒ Object
Returns the value of attribute bot_type.
35 36 37 |
# File 'lib/irc/models/bot.rb', line 35 def bot_type @bot_type end |
#command_details ⇒ Object
Returns the value of attribute command_details.
41 42 43 |
# File 'lib/irc/models/bot.rb', line 41 def command_details @command_details end |
#command_list ⇒ Object
Returns the value of attribute command_list.
42 43 44 |
# File 'lib/irc/models/bot.rb', line 42 def command_list @command_list end |
#command_request ⇒ Object
Returns the value of attribute command_request.
43 44 45 |
# File 'lib/irc/models/bot.rb', line 43 def command_request @command_request end |
#queue_position ⇒ Object
Returns the value of attribute queue_position.
45 46 47 |
# File 'lib/irc/models/bot.rb', line 45 def queue_position @queue_position end |
#queue_size ⇒ Object
Returns the value of attribute queue_size.
46 47 48 |
# File 'lib/irc/models/bot.rb', line 46 def queue_size @queue_size end |
#slots_open ⇒ Object
Returns the value of attribute slots_open.
48 49 50 |
# File 'lib/irc/models/bot.rb', line 48 def slots_open @slots_open end |
#slots_total ⇒ Object
Returns the value of attribute slots_total.
49 50 51 |
# File 'lib/irc/models/bot.rb', line 49 def slots_total @slots_total end |
#transfer_max ⇒ Object
Returns the value of attribute transfer_max.
51 52 53 |
# File 'lib/irc/models/bot.rb', line 51 def transfer_max @transfer_max end |
#transfer_min ⇒ Object
Returns the value of attribute transfer_min.
52 53 54 |
# File 'lib/irc/models/bot.rb', line 52 def transfer_min @transfer_min end |
#transfer_record ⇒ Object
Returns the value of attribute transfer_record.
53 54 55 |
# File 'lib/irc/models/bot.rb', line 53 def transfer_record @transfer_record end |
Instance Method Details
#add_channel(channel) ⇒ Object
84 85 86 87 |
# File 'lib/irc/models/bot.rb', line 84 def add_channel(channel) @channels[channel.hash] = channel return channel end |
#channels ⇒ Object
89 90 91 |
# File 'lib/irc/models/bot.rb', line 89 def channels return @channels.values end |
#create_packet(number, description, size_in_bytes = nil, number_of_downloads = nil) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/irc/models/bot.rb', line 93 def create_packet(number, description, size_in_bytes = nil, number_of_downloads = nil) raise Exception.new("Can't create packet. A packet with the same number does already exist.") if packet(number) != nil packet = Packet.new(:bot => self, :number => number, :description => description, :size_in_bytes => size_in_bytes, :number_of_downloads => number_of_downloads) @packets[number - 1] = packet return packet end |
#merge(other) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/irc/models/bot.rb', line 100 def merge(other) super(other) return if !other.kind_of?(Bot) && !other.kind_of?(IRC::Bot) self.bot_type = other.bot_type self.bandwidth_capacity = other.bandwidth_capacity self.bandwidth_current = other.bandwidth_current self.bandwidth_record = other.bandwidth_record self.command_details = other.command_details self.command_list = other.command_list self.command_request = other.command_request self.queue_position = other.queue_position self.queue_size = other.queue_size self.slots_open = other.slots_open self.slots_total = other.slots_total self.transfer_max = other.transfer_max self.transfer_min = other.transfer_min self.transfer_record = other.transfer_record other.packets do |packet| @packets[packet.number - 1] = packet end end |
#packet(number) ⇒ Object
147 148 149 |
# File 'lib/irc/models/bot.rb', line 147 def packet(number) @packets[number - 1] end |
#packets ⇒ Object
151 152 153 |
# File 'lib/irc/models/bot.rb', line 151 def packets return @packets.compact end |
#update_packet(number, description, size_in_bytes = nil, number_of_downloads = nil) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/irc/models/bot.rb', line 132 def update_packet(number, description, size_in_bytes = nil, number_of_downloads = nil) # Find existing packet by number, or return with a new packet. packet = packet(number) return create_packet(number, description, size_in_bytes, number_of_downloads) if packet == nil # Update already existing packet. packet.description = description packet.size_in_bytes = size_in_bytes packet.number_of_downloads = number_of_downloads return packet end |