def filename_from_pattern(pattern, illust, url)
      pattern.map {|i|
        if i == :image_name
          name = File.basename(url)
          if name =~ /\.(\w+)\?\d+$/
            name += '.' + $1
          end
          name
        elsif i.is_a?(Symbol) then illust.send(i)
        elsif i.respond_to?(:call) then i.call(illust)
        else i
        end
      }.join('')
    end
def filename_from_pattern(pattern, illust, url)
      pattern.map {|i|
        if i == :image_name
          name = File.basename(url)
          if name =~ /\.(\w+)\?\d+$/
            name += '.' + $1
          end
          name
        elsif i.is_a?(Symbol) then illust.send(i)
        elsif i.respond_to?(:call) then i.call(illust)
        else i
        end
      }.join('')
    end
Generate filename from +pattern+ in context of +illust+ and +url+

 @api private
 @param [Array<String, Symbol, #call>] pattern
 @param [Pixiv::Illust] illust
 @param [String] url
 @return [String] filename

 The +pattern+ is an array of string, symbol, or object that responds to +#call+.
 Each component of the +pattern+ is replaced by the following rules and then
 the +pattern+ is concatenated as the returning +filename+.

 * +:image_name+ in the +pattern+ is replaced with the base name of the +url+
 * Any other symbol is replaced with the value of +illust.send(the_symbol)+
 * +#call+-able object is replaced with the value of +the_object.call(illust)+
 * String is left as-is