Class: Facer::Namespace

Inherits:
Object
  • Object
show all
Defined in:
lib/facer/namespace.rb

Overview

Base class to store informations and obtain infos on the namespace

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(linker, name, size, shareMode, owner) ⇒ Namespace

Initialize the class passing a convenient linker reference and infos about the namespace



10
11
12
13
14
15
16
# File 'lib/facer/namespace.rb', line 10

def initialize(linker,name,size,shareMode,owner)
  @linker=linker
  @name=name
  @size=size
  @shareMode=shareMode
  @owner=owner
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/facer/namespace.rb', line 4

def name
  @name
end

#ownerObject (readonly)

Returns the value of attribute owner.



7
8
9
# File 'lib/facer/namespace.rb', line 7

def owner
  @owner
end

#shareModeObject (readonly)

Returns the value of attribute shareMode.



6
7
8
# File 'lib/facer/namespace.rb', line 6

def shareMode
  @shareMode
end

#sizeObject (readonly)

Returns the value of attribute size.



5
6
7
# File 'lib/facer/namespace.rb', line 5

def size
  @size
end

Instance Method Details

#users?Boolean

Retrieve namespace’s user list

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/facer/namespace.rb', line 19

def users?
  if(@owner && @shareMode==:Private)
    t_users=@linker.call("account","users",{"namespaces" => @name})
    out=[]
    if(t_users["status"].to_sym == :success)
       t_users["users"].each_pair do |key,namespace_users|
          out+=namespace_users
       end
       return out
    else
      return []
    end
  else
    return []
  end
  namespaces?.reject {|key,value| !value.owner}
end