Class: Bl::File
Instance Method Summary collapse
- #get(*ids) ⇒ Object
-
#initialize ⇒ File
constructor
A new instance of File.
- #list(path = '') ⇒ Object
Methods included from Requestable
Constructor Details
#initialize ⇒ File
Returns a new instance of File.
5 6 7 8 |
# File 'lib/bl/file.rb', line 5 def initialize(*) @config = Bl::Config.instance super end |
Instance Method Details
#get(*ids) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/bl/file.rb', line 18 def get(*ids) ids.each do |id| res = client.get("projects/#{@config[:project_key]}/files/#{id}") f = ::File.new(res.body.filename, "w") f.write(res.body.content) f.close puts "file #{id} #{res.body.filename} downloaded." end end |
#list(path = '') ⇒ Object
11 12 13 14 15 |
# File 'lib/bl/file.rb', line 11 def list(path='') client.get("projects/#{@config[:project_key]}/files/metadata/#{path}").body.each do |f| puts [f.id, f.type, f.dir, f.name, f.size, f.created, f.updated].join("\t") end end |