Class: Imagetools::Iconextractor
- Inherits:
-
Object
- Object
- Imagetools::Iconextractor
- Defined in:
- lib/imagetools/iconextractor.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ Iconextractor
constructor
A new instance of Iconextractor.
- #run(app_files) ⇒ Object
Constructor Details
#initialize(opts) ⇒ Iconextractor
Returns a new instance of Iconextractor.
46 47 48 |
# File 'lib/imagetools/iconextractor.rb', line 46 def initialize(opts) @opts = opts end |
Class Method Details
.get_app_files(argv) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/imagetools/iconextractor.rb', line 34 def self.get_app_files(argv) app_files = [] argv.each do |arg| if FileTest.directory?(arg) && arg =~ /\.app/ app_path = File.(arg) # puts app_path app_files << app_path end end app_files end |
.run(argv) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/imagetools/iconextractor.rb', line 10 def self.run(argv) opts = {} opt = OptionParser.new(argv) opt. = "Usage: #{opt.program_name} [-h|--help] <app1 app2 app3 ...>" opt.version = VERSION opt.separator('') opt.separator("Options:") opt.on_head('-h', '--help', 'Show this message') do |v| puts opt.help exit end opt.on('-v', '--verbose', 'Verbose message') {|v| opts[:v] = v} opt.on('-o OUTDIR', '--output=OUTDIR', 'Output dir') {|v| opts[:o] = v} opt.parse!(argv) app_files = get_app_files(argv) if app_files.size < 1 puts opt.help exit end command = Iconextractor.new(opts) command.run(app_files) end |
Instance Method Details
#run(app_files) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/imagetools/iconextractor.rb', line 50 def run(app_files) app_files.each do |app_path| icns_path = get_icns_path(app_path) icns_to_png(icns_path) end end |