Sha256: 9b6fd4cca774e0efef46b9e73432d936b801bee2e660f4113a0daf1fb3d706bc

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

# encoding: utf-8
module Nokaya
  class Image

    def self.photo_name nokaya
      path = self.out nokaya
      if nokaya.options[:name]
        "#{path}/#{nokaya.type.to_s}-#{nokaya.options[:name]}.jpg"
      else
        "#{path}/#{nokaya.type.to_s}-#{Time.now.to_i}.jpg"
      end
    end

    def self.save_image path, link
      content = self.get_image link
      f = File.new(path, "wb")
        f.puts(content)
      f.close
    end

    def self.get_image img_link
      begin
        open(img_link).read
      rescue
        abort Status.no_can_do
      end
    end

    private

    def self.out nokaya
      if nokaya.options[:output]
        nokaya.options[:output]
      else
        Dir.home + "/Downloads"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokaya-0.0.8 lib/nokaya/image.rb