class CompositorNode::Resizer

Attributes

height[RW]
source[RW]
width[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/compositor_node/resizer.rb, line 7
def initialize(options = {})
  @source = options[:source]
  @width = options[:width]
  @height = options[:height]
end

Public Instance Methods

execute() click to toggle source
# File lib/compositor_node/resizer.rb, line 13
def execute
  raise MissingDimensionResizeError unless @width || @height
  source = @source.execute
 
  unless @width && @height
    original_width = Engine.width(source)
    original_height = Engine.height(source)

    if @width
      ratio = original_width / @width.to_f
      @height = original_height / ratio
    elsif @height
      ratio = original_height / @height.to_f
      @width = original_width / ratio
    end
  end

  Engine.resize(source, @width, @height)
end