module Meem::Templates

Constants

PATHS

Public Class Methods

find(template) click to toggle source

Find a given template.

template - A String describing a template.

Return a Pathname instance.

# File lib/meem/templates.rb, line 25
def self.find template
  list.find { |file| file.basename.to_s =~ /#{template}/ }
end
list() click to toggle source

List templates.

Returns an Array of Pathname instances.

# File lib/meem/templates.rb, line 13
def self.list
  PATHS.map do |path|
    next unless File.exists?(path)
    path.children.select { |child| child.extname == ".jpg" }
  end.compact.flatten
end
load(template) click to toggle source

Load a template from file or the internet.

template - A String describing a template.

Returns a File.

# File lib/meem/templates.rb, line 34
def self.load template
  if template[/(^https?:\/\/)|(\/)/]
    return open template
  else
    find template
  end
end