Class: Cloudpress::Dropbox::Directory
- Inherits:
-
Object
- Object
- Cloudpress::Dropbox::Directory
- Defined in:
- lib/cloudpress/dropbox/directory.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #directory_contents ⇒ Object
- #files ⇒ Object
- #import! ⇒ Object
-
#initialize(client, path, state) ⇒ Directory
constructor
A new instance of Directory.
- #paths ⇒ Object
- #subdirectories ⇒ Object
Constructor Details
#initialize(client, path, state) ⇒ Directory
Returns a new instance of Directory.
7 8 9 10 11 |
# File 'lib/cloudpress/dropbox/directory.rb', line 7 def initialize(client, path, state) @client = client @path = path @state = state end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/cloudpress/dropbox/directory.rb', line 5 def client @client end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/cloudpress/dropbox/directory.rb', line 5 def path @path end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
5 6 7 |
# File 'lib/cloudpress/dropbox/directory.rb', line 5 def state @state end |
Instance Method Details
#directory_contents ⇒ Object
24 25 26 |
# File 'lib/cloudpress/dropbox/directory.rb', line 24 def directory_contents .with_indifferent_access[:contents] end |
#files ⇒ Object
28 29 30 31 32 |
# File 'lib/cloudpress/dropbox/directory.rb', line 28 def files @files ||= directory_contents.select { |x| x[:is_dir] == false }.map do |x| Cloudpress::Dropbox::File.new(x[:path], x[:rev], state) end end |
#import! ⇒ Object
13 14 15 16 |
# File 'lib/cloudpress/dropbox/directory.rb', line 13 def import! files.each { |x| x.import! } subdirectories.each {|x| x.import! } end |
#paths ⇒ Object
18 19 20 21 22 |
# File 'lib/cloudpress/dropbox/directory.rb', line 18 def paths @paths ||= begin files.map {|x| x.path } + subdirectories.map { |x| x.paths } end.flatten.compact.uniq end |
#subdirectories ⇒ Object
34 35 36 37 38 |
# File 'lib/cloudpress/dropbox/directory.rb', line 34 def subdirectories @subdirectories ||= directory_contents.select { |x| x[:is_dir] == true }.map do |x| Cloudpress::Dropbox::Directory.new(client, x[:path], state) end end |