Class: WOWSQL::StorageFile
- Inherits:
-
Object
- Object
- WOWSQL::StorageFile
- Defined in:
- lib/wowsql/storage.rb
Overview
Storage file/object information.
Instance Attribute Summary collapse
-
#bucket_id ⇒ Object
readonly
Returns the value of attribute bucket_id.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#public_url ⇒ Object
readonly
Returns the value of attribute public_url.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize(data) ⇒ StorageFile
constructor
A new instance of StorageFile.
- #size_gb ⇒ Object
- #size_mb ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(data) ⇒ StorageFile
Returns a new instance of StorageFile.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/wowsql/storage.rb', line 37 def initialize(data) @id = data['id'] || data[:id] || '' @bucket_id = data['bucket_id'] || data[:bucket_id] || '' @name = data['name'] || data[:name] || '' @path = data['path'] || data[:path] || '' @mime_type = data['mime_type'] || data[:mime_type] @size = data['size'] || data[:size] || 0 @metadata = data['metadata'] || data[:metadata] || {} @created_at = data['created_at'] || data[:created_at] @public_url = data['public_url'] || data[:public_url] end |
Instance Attribute Details
#bucket_id ⇒ Object (readonly)
Returns the value of attribute bucket_id.
34 35 36 |
# File 'lib/wowsql/storage.rb', line 34 def bucket_id @bucket_id end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
34 35 36 |
# File 'lib/wowsql/storage.rb', line 34 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
34 35 36 |
# File 'lib/wowsql/storage.rb', line 34 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
34 35 36 |
# File 'lib/wowsql/storage.rb', line 34 def @metadata end |
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
34 35 36 |
# File 'lib/wowsql/storage.rb', line 34 def mime_type @mime_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
34 35 36 |
# File 'lib/wowsql/storage.rb', line 34 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
34 35 36 |
# File 'lib/wowsql/storage.rb', line 34 def path @path end |
#public_url ⇒ Object (readonly)
Returns the value of attribute public_url.
34 35 36 |
# File 'lib/wowsql/storage.rb', line 34 def public_url @public_url end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
34 35 36 |
# File 'lib/wowsql/storage.rb', line 34 def size @size end |
Instance Method Details
#size_gb ⇒ Object
53 54 55 |
# File 'lib/wowsql/storage.rb', line 53 def size_gb @size / (1024.0 ** 3) end |
#size_mb ⇒ Object
49 50 51 |
# File 'lib/wowsql/storage.rb', line 49 def size_mb @size / (1024.0 * 1024.0) end |
#to_s ⇒ Object Also known as: inspect
57 58 59 |
# File 'lib/wowsql/storage.rb', line 57 def to_s "StorageFile(path=#{@path.inspect}, size=#{'%.2f' % size_mb}MB)" end |