Class: Megar::File

Inherits:
Object
  • Object
show all
Includes:
CatalogItem
Defined in:
lib/megar/catalog/file.rb

Overview

File collection item

Instance Attribute Summary collapse

Attributes included from CatalogItem

#id, #key, #name, #parent_folder_id, #payload, #session, #type

Instance Method Summary collapse

Methods included from CatalogItem

#==, #[], #add, #attributes=, #collection, #default_parent_folder, #each, #find_all_by_parent_folder_id, #find_all_by_type, #find_by_id, #find_by_name, #find_by_type, #initialize, #parent_folder, #reset!, #resource_class

Instance Attribute Details

#decomposed_keyObject

Decomposed form the key



6
7
8
# File 'lib/megar/catalog/file.rb', line 6

def decomposed_key
  @decomposed_key
end

#sizeObject

The file size



9
10
11
# File 'lib/megar/catalog/file.rb', line 9

def size
  @size
end

Instance Method Details

#bodyObject

Returns the body content of the file



18
19
20
# File 'lib/megar/catalog/file.rb', line 18

def body
  downloader.content
end

#downloaderObject

Returns the a one-shot downloader



23
24
25
# File 'lib/megar/catalog/file.rb', line 23

def downloader
  Megar::FileDownloader.new(file: self)
end

#to_sObject

Return a pretty version of the file record



13
14
15
# File 'lib/megar/catalog/file.rb', line 13

def to_s
  format("%16d bytes  %-10s  %-60s", size.to_i, id, name)
end