Class: PrefixedExtension

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

Direct Known Subclasses

TagSets, Visibility

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ PrefixedExtension

Returns a new instance of PrefixedExtension.



2
3
4
# File 'lib/flickrup/ext/prefixed_extension.rb', line 2

def initialize(config)
  @config = config
end

Instance Method Details

#values(prefix_key, ctx) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/flickrup/ext/prefixed_extension.rb', line 6

def values(prefix_key, ctx)

  prefix = @config[prefix_key]

  if prefix
    all_tags = ctx.file.tags

    (selected_tags, tags) = all_tags.partition do |x|
      x.start_with?("#{prefix}")
    end

    selected_tags.map do |x|
      x[(prefix.length)..x.length]
    end
  else
    []
  end
end