class Temp::Tempfile
Attributes
erb_files[R]
ignore_files[R]
info[R]
options[R]
Public Class Methods
new(dir, options = {})
click to toggle source
Loads a Tempfile
in the specified directory. Options
can be passed so that they can be accessed from the Tempfile
.
# File lib/temp/tempfile.rb, line 10 def initialize(dir, options = {}) @dir = File.expand_path(dir) @file = File.join(@dir, 'Tempfile') @options = options @info = {} @ignore_files = [] @erb_files = [] instance_eval File.read(@file) if File.file? @file end
Public Instance Methods
desc(str)
click to toggle source
Sets the template description
# File lib/temp/tempfile.rb, line 31 def desc(str) info[:desc] = str end
get_binding()
click to toggle source
Gets the object's binding
# File lib/temp/tempfile.rb, line 21 def get_binding binding end
ignore(*files)
click to toggle source
Adds files to the ignore list by expanding the given glob(s)
# File lib/temp/tempfile.rb, line 36 def ignore(*files) @ignore_files |= files.map do |file| Dir.glob(File.join(@dir, file)).map { |f| f.sub(@dir + '/', '') } end.flatten end
name(str)
click to toggle source
Sets the template name
# File lib/temp/tempfile.rb, line 26 def name(str) info[:name] = str end
use_erb(*files)
click to toggle source
Adds files to the ERB list by expanding the given glob(s)
# File lib/temp/tempfile.rb, line 43 def use_erb(*files) @erb_files |= files.map do |file| Dir.glob(File.join(@dir, file)).map { |f| f.sub(@dir + '/', '') } end.flatten end