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, Convertables::Convertable::FORMAT_REGEX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Convertables::Convertable

convert_output_formats, included, #method_missing, #respond_to_missing?

Constructor Details

#initialize(file, format, checksum, original = false) ⇒ 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, original = false)
  raise Cloudkeeper::Errors::ArgumentError, 'file, format and checksum cannot be nil nor empty'\
    if file.blank? || format.blank? || checksum.blank?

  @file = file
  @checksum = checksum
  @format = format
  @original = original

  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

#checksum ⇒ Object

Returns the value of attribute checksum.



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

def checksum
  @checksum
end

#file ⇒ Object

Returns the value of attribute file.



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

def file
  @file
end

#format ⇒ Object

Returns the value of attribute format.



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

def format
  @format
end

#original ⇒ Object

Returns the value of attribute original.



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

def original
  @original
end