Class: IconGenerator::TouchBuilder
- Inherits:
-
Object
- Object
- IconGenerator::TouchBuilder
- Includes:
- Validator
- Defined in:
- lib/icon_generator/touch_builder.rb
Instance Method Summary collapse
-
#build(source, destination) ⇒ Object
Builds apple-touch-icons from the given source file.
-
#build_single(source, destination) ⇒ Object
Builds a single 152x152 apple-touch-icon-precomposed from the given source file.
-
#build_size(source, size, new_image) ⇒ Object
Builds a given size of apple-touch-icon.
-
#initialize ⇒ TouchBuilder
constructor
Initializes the default image sizes.
Methods included from Validator
#validate_arguments, #validate_file_status
Constructor Details
#initialize ⇒ TouchBuilder
Initializes the default image sizes.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/icon_generator/touch_builder.rb', line 6 def initialize @sizes = [ '152x152', '144x144', '120x120', '114x114', '76x76', '72x72', '57x57', ] end |
Instance Method Details
#build(source, destination) ⇒ Object
Builds apple-touch-icons from the given source file.
22 23 24 25 26 27 28 29 30 |
# File 'lib/icon_generator/touch_builder.rb', line 22 def build(source, destination) @sizes.each do |size| new_image = "#{destination}/apple-touch-icon-#{size}-precomposed.png" build_size(source, size, new_image) if size == '57x57' build_size(source, '57x57', "#{destination}/apple-touch-icon-precomposed.png") end end end |
#build_single(source, destination) ⇒ Object
Builds a single 152x152 apple-touch-icon-precomposed from the given source file.
37 38 39 |
# File 'lib/icon_generator/touch_builder.rb', line 37 def build_single(source, destination) build_size(source, '152x152', "#{destination}/apple-touch-icon-precomposed.png") end |
#build_size(source, size, new_image) ⇒ Object
Builds a given size of apple-touch-icon.
46 47 48 49 50 |
# File 'lib/icon_generator/touch_builder.rb', line 46 def build_size(source, size, new_image) %x[convert '#{source}' -resize #{size}! #{new_image}] validate_file_status new_image puts Thor::Shell::Color.new.set_color("Built #{new_image}", :green) end |