Class: Rmega::Storage
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #download(public_url, path) ⇒ Object
-
#initialize(session) ⇒ Storage
constructor
A new instance of Storage.
- #nodes ⇒ Object
- #quota ⇒ Object
- #root ⇒ Object
- #total_space ⇒ Object
- #trash ⇒ Object
- #used_space ⇒ Object
Methods included from Loggable
Constructor Details
#initialize(session) ⇒ Storage
Returns a new instance of Storage.
9 10 11 |
# File 'lib/rmega/storage.rb', line 9 def initialize(session) @session = session end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
7 8 9 |
# File 'lib/rmega/storage.rb', line 7 def session @session end |
Instance Method Details
#download(public_url, path) ⇒ Object
38 39 40 |
# File 'lib/rmega/storage.rb', line 38 def download(public_url, path) Nodes::Factory.build_from_url(session, public_url).download(path) end |
#nodes ⇒ Object
25 26 27 28 |
# File 'lib/rmega/storage.rb', line 25 def nodes results = session.request(a: 'f', c: 1)['f'] results.map { |node_data| Nodes::Factory.build(session, node_data) } end |
#quota ⇒ Object
21 22 23 |
# File 'lib/rmega/storage.rb', line 21 def quota session.request(a: 'uq', strg: 1) end |
#root ⇒ Object
34 35 36 |
# File 'lib/rmega/storage.rb', line 34 def root @root ||= nodes.find { |n| n.type == :root } end |
#total_space ⇒ Object
17 18 19 |
# File 'lib/rmega/storage.rb', line 17 def total_space quota['mstrg'] end |
#trash ⇒ Object
30 31 32 |
# File 'lib/rmega/storage.rb', line 30 def trash @trash ||= nodes.find { |n| n.type == :trash } end |
#used_space ⇒ Object
13 14 15 |
# File 'lib/rmega/storage.rb', line 13 def used_space quota['cstrg'] end |