Class: Versionable::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/versionable/version.rb

Defined Under Namespace

Classes: Crop

Constant Summary collapse

FIT_IN =
'fit-in'.freeze
SMART =
'smart'.freeze
UNSAFE =
'unsafe'.freeze
META =
'meta'.freeze
HALIGNEMENTS =
%w(left center right).freeze
VALIGNEMENTS =
%w(top middle bottom).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image, parameters, &blk) ⇒ Version



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/versionable/version.rb', line 15

def initialize(image, parameters, &blk)
  @image = image
  @height = parameters.fetch(:height) { 0 }
  @width = parameters.fetch(:width) { 0 }
  @fit_in = parameters.fetch(:fit_in) { false }
  @smart = parameters.fetch(:smart) { false }
  @meta = parameters.fetch(:meta) { false }
  @filters = []

  instance_eval(&blk) if block_given?
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



14
15
16
# File 'lib/versionable/version.rb', line 14

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



14
15
16
# File 'lib/versionable/version.rb', line 14

def width
  @width
end

Instance Method Details

#calculate_metadataObject



35
36
37
38
39
40
# File 'lib/versionable/version.rb', line 35

def 
  {
    width: calculate_width,
    height: calculate_height
  }
end

#urlObject



27
28
29
30
31
32
33
# File 'lib/versionable/version.rb', line 27

def url
  [
    server,
    sign,
    options_url
  ].reject(&:nil?).join('/')
end