Class: Images::Builder

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

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Builder

Returns a new instance of Builder.



4
5
6
7
# File 'lib/images/builder.rb', line 4

def initialize(args)
  @directory = args.fetch(:directory)
  @helper = args.fetch(:helper)
end

Instance Method Details

#call(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/images/builder.rb', line 9

def call(options)
  images_paths
    .map { |path| get_short_path(path) }
    .select { |path| options.whitelist.include?(path.extname.slice(1,10)) }
    .reduce({}) { |acc, path|
      split = split_path(path)
      asset = @helper.call(path)
      append_nested_path(acc, split, asset)
    }
end