Class: VPOPMail::User

Inherits:
Object
  • Object
show all
Defined in:
lib/vpopmail/user.rb

Overview


class: User {{{

Constant Summary collapse

@@logger =

class attribute: logger {{{

nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(p_domain) ⇒ User


method: initialize {{{



34
35
36
37
# File 'lib/vpopmail/user.rb', line 34

def initialize(p_domain)
	@name   = @path = ""
	@domain = p_domain
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



20
21
22
# File 'lib/vpopmail/user.rb', line 20

def domain
  @domain
end

#nameObject

Returns the value of attribute name.



20
21
22
# File 'lib/vpopmail/user.rb', line 20

def name
  @name
end

#pathObject

Returns the value of attribute path.



20
21
22
# File 'lib/vpopmail/user.rb', line 20

def path
  @path
end

Class Method Details

.FindUsers(p_domain, p_name = nil) ⇒ Object


class method: FindUsers {{{

Raises:

  • (ArgumentError)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vpopmail/user.rb', line 41

def self.FindUsers(p_domain, p_name = nil)
	raise ArgumentError unless p_domain.kind_of?(Domain)
	cmdString = "#{VPOPMail::CFG['VPOP Bin']}/vuserinfo -n -d"
	if p_name.nil? or p_name.empty? then
		cmdString = cmdString + " -D #{p_domain.name}"
	else
		raise ArgumentError unless p_name.kind_of?(String)
		cmdString = cmdString + " #{p_name}@#{p_domain.name}"
	end
	cmd = IO.popen(cmdString, "w+")
	cmd.close_write

	users = Array.new
	user  = User.new(p_domain)
	getName = true
	while line = cmd.gets do
		line = line.gsub(/[\r\n]*$/, "")
		next if line.empty?
		if getName then
			user.name = line
		else
			user.path = line
			users << user
			user = User.new(p_domain)
		end
		getName = !getName
	end
	return users
end

.loggerObject



26
# File 'lib/vpopmail/user.rb', line 26

def self.logger ;            @@logger ; end

.logger=(p_object) ⇒ Object



27
# File 'lib/vpopmail/user.rb', line 27

def self.logger=(p_object) ; @@logger = p_object ; end

Instance Method Details

#loggerObject



28
# File 'lib/vpopmail/user.rb', line 28

def logger ;                 @@logger ; end

#logger=(p_object) ⇒ Object



29
# File 'lib/vpopmail/user.rb', line 29

def logger=(p_object) ;      @@logger = p_object ; end

#to_sObject


method: to_s {{{



79
80
81
# File 'lib/vpopmail/user.rb', line 79

def to_s
	return to_xml
end

#to_xmlObject


method: to_xml {{{



73
74
75
# File 'lib/vpopmail/user.rb', line 73

def to_xml
	return "<User name=\"#{@name}\" path=\"#{@path}\" />"
end