module Neutrino::Processing::Nano

Attributes

cached[RW]

Public Instance Methods

convert!(format) click to toggle source
# File lib/neutrino/processing/nano.rb, line 8
def convert!(format)
  pathname = converted_pathname(format)

  manipulate!('-format', format)

  if pathname != File.expand_path(cached.path)
    File.delete(cached)

    self.cached = File.open(pathname)
  end
end
manipulate!(*arguments) click to toggle source
# File lib/neutrino/processing/nano.rb, line 24
def manipulate!(*arguments)
  pid = Kernel.spawn(build_command(arguments))

  Process.wait(pid)
end
resize!(dimensions) click to toggle source
# File lib/neutrino/processing/nano.rb, line 20
def resize!(dimensions)
  manipulate!('-resize', dimensions)
end

Private Instance Methods

build_command(arguments) click to toggle source
# File lib/neutrino/processing/nano.rb, line 32
def build_command(arguments)
  Shellwords.join(['mogrify'] + arguments + [cached.path])
end
converted_pathname(format) click to toggle source
# File lib/neutrino/processing/nano.rb, line 36
def converted_pathname(format)
  File.expand_path(cached.path.sub(/(\.\w*)?$/, ".#{format}"))
end