Method: Raccdoc::Forum#initialize
- Defined in:
- lib/raccdoc/forum.rb
#initialize(socket, forum = 0) ⇒ Forum
Sets the active forum on the server to the specified forum number (0) or name (Lobby, Program), then returns a new Raccdoc::Forum object.
There are five instance variables exposed through attr_reader:
-
id - The forum ID number
-
name - The forum name
-
admin - The name of the forum administrator
-
anonymous - either true, false, or force, depending on whether the anonymous posting option is on, off, or required
-
private - True if the forum is private (invite-only), false otherwise
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/raccdoc/forum.rb', line 19 def initialize(socket, forum = 0) @socket = socket @socket.puts "TOPIC #{forum.to_s}" response = @socket.readline.chomp unless response.match(/^2/) raise ResponseError, response end @headers = {} tuples = response.split(/\t/) tuples.delete_at(0) tuples.each do |pair| (key, value) = pair.split(/:/) @headers[key.downcase.to_sym] = value end flags = @headers[:flags].split(',') if flags.include?("forceanonymous") @anonymous = "force" elsif flags.include?("cananonymous") @anonymous = true else @anonymous = false end @private = flags.include?("private") ? true : false @id = @headers[:topic] @name = @headers[:name] @admin = @headers[:admin].split('/')[1] end |