Class: Gastly::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/gastly/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image) ⇒ Image

Returns a new instance of Image.

Parameters:

  • image (MiniMagick::Image)

    Instance of MiniMagick::Image



6
7
8
# File 'lib/gastly/image.rb', line 6

def initialize(image)
  @image = image
end

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image.



3
4
5
# File 'lib/gastly/image.rb', line 3

def image
  @image
end

Instance Method Details

#format(ext) ⇒ MiniMagick::Image

Returns Instance.

Parameters:

  • ext (String)

    Image extension

Returns:

  • (MiniMagick::Image)

    Instance



19
20
21
# File 'lib/gastly/image.rb', line 19

def format(ext)
  image.format(ext)
end

#resize(width:, height:) ⇒ Object

Parameters:

  • width (Fixnum)

    Image width

  • height (Fixnum)

    Image height



12
13
14
15
# File 'lib/gastly/image.rb', line 12

def resize(width:, height:)
  dimensions = "#{width}x#{height}"
  image.resize(dimensions)
end

#save(output) ⇒ String

Returns Full path to image.

Parameters:

  • output (String)

    Full path to image

Returns:

  • (String)

    Full path to image



25
26
27
28
# File 'lib/gastly/image.rb', line 25

def save(output)
  image.write(output)
  output
end