Class: Etna::Clients::Metis::File
- Inherits:
-
Object
- Object
- Etna::Clients::Metis::File
- Defined in:
- lib/etna/clients/metis/models.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #bucket_name ⇒ Object
- #download_path ⇒ Object
- #download_url ⇒ Object
- #file_hash ⇒ Object
- #file_name ⇒ Object
- #file_path ⇒ Object
- #folder_id ⇒ Object
-
#initialize(raw = {}) ⇒ File
constructor
A new instance of File.
- #project_name ⇒ Object
- #size ⇒ Object
- #updated_at ⇒ Object
- #with_containing_folder(folder) ⇒ Object
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
#raw ⇒ Object (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_name ⇒ Object
302 303 304 |
# File 'lib/etna/clients/metis/models.rb', line 302 def bucket_name raw[:bucket_name] end |
#download_path ⇒ Object
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_url ⇒ Object
312 313 314 |
# File 'lib/etna/clients/metis/models.rb', line 312 def download_url raw[:download_url] || '' end |
#file_hash ⇒ Object
329 330 331 |
# File 'lib/etna/clients/metis/models.rb', line 329 def file_hash raw[:file_hash] end |
#file_name ⇒ Object
316 317 318 |
# File 'lib/etna/clients/metis/models.rb', line 316 def file_name raw[:file_name] end |
#file_path ⇒ Object
294 295 296 |
# File 'lib/etna/clients/metis/models.rb', line 294 def file_path raw[:file_path] end |
#folder_id ⇒ Object
333 334 335 |
# File 'lib/etna/clients/metis/models.rb', line 333 def folder_id raw[:folder_id] end |
#project_name ⇒ Object
298 299 300 |
# File 'lib/etna/clients/metis/models.rb', line 298 def project_name raw[:project_name] end |
#size ⇒ Object
325 326 327 |
# File 'lib/etna/clients/metis/models.rb', line 325 def size raw[:size] end |
#updated_at ⇒ Object
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 |