Class: WOWSQL::StorageFile

Inherits:
Object
  • Object
show all
Defined in:
lib/wowsql/storage.rb

Overview

Storage file/object information.

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idObject (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_atObject (readonly)

Returns the value of attribute created_at.



34
35
36
# File 'lib/wowsql/storage.rb', line 34

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



34
35
36
# File 'lib/wowsql/storage.rb', line 34

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



34
35
36
# File 'lib/wowsql/storage.rb', line 34

def 
  @metadata
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



34
35
36
# File 'lib/wowsql/storage.rb', line 34

def mime_type
  @mime_type
end

#nameObject (readonly)

Returns the value of attribute name.



34
35
36
# File 'lib/wowsql/storage.rb', line 34

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



34
35
36
# File 'lib/wowsql/storage.rb', line 34

def path
  @path
end

#public_urlObject (readonly)

Returns the value of attribute public_url.



34
35
36
# File 'lib/wowsql/storage.rb', line 34

def public_url
  @public_url
end

#sizeObject (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_gbObject



53
54
55
# File 'lib/wowsql/storage.rb', line 53

def size_gb
  @size / (1024.0 ** 3)
end

#size_mbObject



49
50
51
# File 'lib/wowsql/storage.rb', line 49

def size_mb
  @size / (1024.0 * 1024.0)
end

#to_sObject 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