Class: Facer::Account
- Inherits:
-
Object
- Object
- Facer::Account
- Defined in:
- lib/facer/account.rb
Overview
Base class to store security informations and obtain infos on the account
Instance Attribute Summary collapse
-
#apiKey ⇒ Object
readonly
Returns the value of attribute apiKey.
-
#apiSecret ⇒ Object
readonly
Returns the value of attribute apiSecret.
-
#applicationName ⇒ Object
readonly
Returns the value of attribute applicationName.
Instance Method Summary collapse
-
#initialize(linker, app_name, api_key, api_secret) ⇒ Account
constructor
Initialize the class passing a convenient linker reference.
-
#limits? ⇒ Boolean
Retrieve informations about current account’s limits.
-
#namespaces? ⇒ Boolean
Obtain all account’s accessible namespaces.
-
#owned_namespaces? ⇒ Boolean
Obtain all the namespaces owned by the account owner (public and private).
-
#private_namespaces? ⇒ Boolean
Obtain all account’s private namespaces.
Constructor Details
#initialize(linker, app_name, api_key, api_secret) ⇒ Account
Initialize the class passing a convenient linker reference
9 10 11 12 13 14 |
# File 'lib/facer/account.rb', line 9 def initialize(linker, app_name,api_key,api_secret) @linker=linker @applicationName=app_name @apiKey=api_key @apiSecret=api_secret end |
Instance Attribute Details
#apiKey ⇒ Object (readonly)
Returns the value of attribute apiKey.
5 6 7 |
# File 'lib/facer/account.rb', line 5 def apiKey @apiKey end |
#apiSecret ⇒ Object (readonly)
Returns the value of attribute apiSecret.
6 7 8 |
# File 'lib/facer/account.rb', line 6 def apiSecret @apiSecret end |
#applicationName ⇒ Object (readonly)
Returns the value of attribute applicationName.
4 5 6 |
# File 'lib/facer/account.rb', line 4 def applicationName @applicationName end |
Instance Method Details
#limits? ⇒ Boolean
Retrieve informations about current account’s limits
42 43 44 45 46 47 48 49 |
# File 'lib/facer/account.rb', line 42 def limits? out=@linker.call("account","limits") if(out["status"].to_sym == :success) return out["usage"] else return nil end end |
#namespaces? ⇒ Boolean
Obtain all account’s accessible namespaces
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/facer/account.rb', line 17 def namespaces? t_namespaces=@linker.call("account","namespaces") if(t_namespaces["status"].to_sym == :success) out={} t_namespaces["namespaces"].each do |namespace| nm=Namespace.new(@linker,namespace["name"],namespace["size"],namespace["share_mode"].to_sym,namespace["owner"]) out[nm.name]=nm end return out else return {} end end |
#owned_namespaces? ⇒ Boolean
Obtain all the namespaces owned by the account owner (public and private)
32 33 34 |
# File 'lib/facer/account.rb', line 32 def owned_namespaces? namespaces?.reject {|key,value| !value.owner} end |
#private_namespaces? ⇒ Boolean
Obtain all account’s private namespaces
37 38 39 |
# File 'lib/facer/account.rb', line 37 def private_namespaces? owned_namespaces?.reject {|key,value| value.shareMode!=:Private} end |