Class: ShatteredMachine::Io
- Inherits:
-
Object
- Object
- ShatteredMachine::Io
- Defined in:
- lib/shattered_machine/io.rb
Overview
Find all png or jpg image in a given directory. Generate output filename that doesn’t overwrite existing file.
Defined Under Namespace
Classes: Paths
Instance Attribute Summary collapse
-
#output_filename ⇒ Object
Returns the value of attribute output_filename.
Instance Method Summary collapse
-
#initialize(input_path, output_folder, output_filename) ⇒ Io
constructor
A new instance of Io.
-
#jpg_images ⇒ Array<Paths>
List of all jpg images in input_path.
-
#png_images ⇒ Array<Paths>
List of all png images in input_path.
Constructor Details
#initialize(input_path, output_folder, output_filename) ⇒ Io
Returns a new instance of Io.
12 13 14 15 16 |
# File 'lib/shattered_machine/io.rb', line 12 def initialize(input_path, output_folder, output_filename) @input_path = input_path @output_folder = output_folder @output_filename = output_filename end |
Instance Attribute Details
#output_filename ⇒ Object
Returns the value of attribute output_filename.
7 8 9 |
# File 'lib/shattered_machine/io.rb', line 7 def output_filename @output_filename end |
Instance Method Details
#jpg_images ⇒ Array<Paths>
Returns list of all jpg images in input_path.
28 29 30 31 32 33 34 |
# File 'lib/shattered_machine/io.rb', line 28 def jpg_images return single_image_io if extension_included?(JPG_EXTENSIONS, @input_path) images_in_directory(JPG_EXTENSIONS).map do |img| Paths.new("#{@input_path}/#{img}", generate_output_filename(img)) end end |
#png_images ⇒ Array<Paths>
Returns list of all png images in input_path.
19 20 21 22 23 24 25 |
# File 'lib/shattered_machine/io.rb', line 19 def png_images return single_image_io if extension_included?(PNG_EXTENSIONS, @input_path) images_in_directory(PNG_EXTENSIONS).map do |img| Paths.new("#{@input_path}/#{img}", generate_output_filename(img)) end end |