Class: Cloudkeeper::Entities::ImageFile

Inherits:
Object
  • Object
show all
Includes:
Convertables::Convertable
Defined in:
lib/cloudkeeper/entities/image_file.rb

Constant Summary

Constants included from Convertables::Convertable

Convertables::Convertable::CONVERT_OUTPUT_FORMATS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Convertables::Convertable

#convert_output_formats, #format_regex, included, #method_missing, #respond_to_missing?

Constructor Details

#initialize(file, format, checksum, size) ⇒ ImageFile

Returns a new instance of ImageFile.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cloudkeeper/entities/image_file.rb', line 8

def initialize(file, format, checksum, size)
  raise Cloudkeeper::Errors::ArgumentError, 'file, format, checksum and size cannot be nil nor empty'\
    if file.blank? || format.blank? || checksum.blank? || size.blank?

  @file = file
  @format = format
  @checksum = checksum
  @size = size

  format_const_symbol = format.to_s.classify.to_sym
  extend(Cloudkeeper::Entities::Convertables.const_get(format_const_symbol)) \
    if Cloudkeeper::Entities::Convertables.const_defined? format_const_symbol
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Cloudkeeper::Entities::Convertables::Convertable

Instance Attribute Details

#checksumObject

Returns the value of attribute checksum.



4
5
6
# File 'lib/cloudkeeper/entities/image_file.rb', line 4

def checksum
  @checksum
end

#fileObject

Returns the value of attribute file.



4
5
6
# File 'lib/cloudkeeper/entities/image_file.rb', line 4

def file
  @file
end

#formatObject

Returns the value of attribute format.



4
5
6
# File 'lib/cloudkeeper/entities/image_file.rb', line 4

def format
  @format
end

#sizeObject

Returns the value of attribute size.



4
5
6
# File 'lib/cloudkeeper/entities/image_file.rb', line 4

def size
  @size
end