Class: Megar::File
- Inherits:
-
Object
- Object
- Megar::File
- Includes:
- CatalogItem
- Defined in:
- lib/megar/catalog/file.rb
Overview
File collection item
Instance Attribute Summary collapse
-
#decomposed_key ⇒ Object
Decomposed form the
key
. -
#size ⇒ Object
The file size.
Attributes included from CatalogItem
#id, #key, #name, #parent_folder_id, #payload, #session, #type
Instance Method Summary collapse
-
#body ⇒ Object
Returns the body content of the file.
-
#downloader ⇒ Object
Returns the a one-shot downloader.
-
#to_s ⇒ Object
Return a pretty version of the file record.
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_key ⇒ Object
Decomposed form the key
6 7 8 |
# File 'lib/megar/catalog/file.rb', line 6 def decomposed_key @decomposed_key end |
#size ⇒ Object
The file size
9 10 11 |
# File 'lib/megar/catalog/file.rb', line 9 def size @size end |
Instance Method Details
#body ⇒ Object
Returns the body content of the file
18 19 20 |
# File 'lib/megar/catalog/file.rb', line 18 def body downloader.content end |
#downloader ⇒ Object
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_s ⇒ Object
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 |