Class: TagSets

Inherits:
PrefixedExtension show all
Includes:
Logging
Defined in:
lib/flickrup/ext/tag_sets.rb

Instance Method Summary collapse

Methods included from Logging

logger, #logger, pre_init

Methods inherited from PrefixedExtension

#values

Constructor Details

#initialize(config, delegate, context) ⇒ TagSets

Returns a new instance of TagSets.



7
8
9
10
11
# File 'lib/flickrup/ext/tag_sets.rb', line 7

def initialize(config, delegate, context)
  super(config)
  @delegate = delegate
  @flickr = context[:flickr_client]
end

Instance Method Details

#archive(ctx) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/flickrup/ext/tag_sets.rb', line 26

def archive(ctx)
  sets = values(:tagsetprefix, ctx).uniq

  if sets.length == 1
    ctx.properties[:subdir] = sets[0]
    set_date = @flickr.date_of_set(sets[0])
    ctx.properties[:date_taken] = set_date
  end
  @delegate.archive(ctx)
end

#upload(ctx) ⇒ Object



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

def upload(ctx)
  sets = values(:tagsetprefix, ctx).uniq

  uploaded = @delegate.upload(ctx)

  unless ctx.properties[UploaderConstants::NO_UPLOAD] == true
    sets.each do |set|
      logger.debug("Adding #{ctx.file.filename} to set: #{set}")
      @flickr.add_to_set(uploaded, set, ctx.file.date_created)
    end
  end
end