Class: AssociatedFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/flickrup/ext/associated_files.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, delegate, context) ⇒ AssociatedFiles

Returns a new instance of AssociatedFiles.



3
4
5
6
7
8
9
10
11
12
# File 'lib/flickrup/ext/associated_files.rb', line 3

def initialize(config, delegate, context)
  @delegate = delegate
  if config.has_key?(:associated_files)
    @replacements = config[:associated_files].map do |x|
      extract_pair(x)
    end
  else
    @replacements = []
  end
end

Instance Method Details

#archive(ctx) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/flickrup/ext/associated_files.rb', line 14

def archive(ctx)
  @delegate.archive(ctx)
  @replacements.map do |x|
    other = ctx.properties[:filename].gsub(*x)
    if File.exist? other
      @delegate.archive(ctx.with_properties({:filename => other}))
    end
  end
end