Class: Etna::Clients::Metis::File

Inherits:
Object
  • Object
show all
Defined in:
lib/etna/clients/metis/models.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw = {}) ⇒ File

Returns a new instance of File.



283
284
285
# File 'lib/etna/clients/metis/models.rb', line 283

def initialize(raw = {})
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



281
282
283
# File 'lib/etna/clients/metis/models.rb', line 281

def raw
  @raw
end

Instance Method Details

#bucket_nameObject



302
303
304
# File 'lib/etna/clients/metis/models.rb', line 302

def bucket_name
  raw[:bucket_name]
end

#download_pathObject



306
307
308
309
310
# File 'lib/etna/clients/metis/models.rb', line 306

def download_path
  raw[:download_url].nil? ?
      "/#{project_name}/download/#{bucket_name}/#{file_path}" :
      raw[:download_url].sub(%r!^https://[^/]*?/!, '/')
end

#download_urlObject



312
313
314
# File 'lib/etna/clients/metis/models.rb', line 312

def download_url
  raw[:download_url] || ''
end

#file_hashObject



329
330
331
# File 'lib/etna/clients/metis/models.rb', line 329

def file_hash
  raw[:file_hash]
end

#file_nameObject



316
317
318
# File 'lib/etna/clients/metis/models.rb', line 316

def file_name
  raw[:file_name]
end

#file_pathObject



294
295
296
# File 'lib/etna/clients/metis/models.rb', line 294

def file_path
  raw[:file_path]
end

#folder_idObject



333
334
335
# File 'lib/etna/clients/metis/models.rb', line 333

def folder_id
  raw[:folder_id]
end

#project_nameObject



298
299
300
# File 'lib/etna/clients/metis/models.rb', line 298

def project_name
  raw[:project_name]
end

#sizeObject



325
326
327
# File 'lib/etna/clients/metis/models.rb', line 325

def size
  raw[:size]
end

#updated_atObject



320
321
322
323
# File 'lib/etna/clients/metis/models.rb', line 320

def updated_at
  time = raw[:updated_at]
  time.nil? ? nil : Time.parse(time)
end

#with_containing_folder(folder) ⇒ Object



287
288
289
290
291
292
# File 'lib/etna/clients/metis/models.rb', line 287

def with_containing_folder(folder)
  folder_path = folder.is_a?(Folder) ? folder.folder_path : folder
  File.new({}.update(self.raw).update({
    file_path: ::File.join(folder_path, self.file_name)
  }))
end