Class: MobImageFactory

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

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ MobImageFactory

Returns a new instance of MobImageFactory.



2
3
4
# File 'lib/mob_image_factory.rb', line 2

def initialize(args)
  @args = args
end

Instance Method Details

#produceObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/mob_image_factory.rb', line 6

def produce
  if @args.empty? || @args.size < 2
    return usage
  end
  @type = @args[0]
  @infilename = @args[1]
  @outfilename = @args[2].nil? ? @infilename : @args[2]

  system "identify #{@infilename}"

  if @type == 'android_icon'
    #Android App icons
    convert 192, "android", "xxxhdpi"
    convert 144, "android", "xxhdpi"
    convert 96, "android", "xhdpi"
    convert 72, "android", "hdpi"
    convert 48, "android", "mdpi"
  elsif @type == 'android_notification_icon'
    #Android Notification icons
    convert_greyscale 96, "android", "xxxhdpi"
    convert_greyscale 72, "android", "xxhdpi"
    convert_greyscale 48, "android", "xhdpi"
    convert_greyscale 36, "android", "hdpi"
    convert_greyscale 24, "android", "mdpi"
  else
    return usage
  end

  "Done"
end