class DateNamedFile::OldDatedFile
Attributes
dft[R]
embedded_date[R]
template[R]
Public Class Methods
from_date(dft, date_ish)
click to toggle source
# File lib/date_named_file/dated_file.rb, line 103 def self.from_date(dft, date_ish) self.new(dft, dft.filename_for(date_ish)) end
from_filename(dft, filename)
click to toggle source
# File lib/date_named_file/dated_file.rb, line 98 def self.from_filename(dft, filename) raise Error.new("String #{filename} does not match template '#{dft.template}'") unless dft.match? filename self.new(dft, filename) end
new(dft, filename)
click to toggle source
# File lib/date_named_file/dated_file.rb, line 91 def initialize(dft, filename) @path = Pathname.new(filename) self.__setobj__ @path @dft = dft @embedded_date = dft.datetime_from_filename(@path.basename.to_s) end
Public Instance Methods
==(other)
click to toggle source
# File lib/date_named_file/dated_file.rb, line 116 def ==(other) self.basename.to_s == other.basename.to_s end
inspect()
click to toggle source
# File lib/date_named_file/dated_file.rb, line 124 def inspect "#<#{self.class.to_s}:#{@path} template=#{@dft.template}:#{object_id}>" end
open()
click to toggle source
# File lib/date_named_file/dated_file.rb, line 107 def open raise "File #{@path.to_s} doesn't exist" unless @path.exist? begin Zlib::GzipReader.open(@path) rescue Zlib::GzipFile::Error File.open(@path) end end
pretty_inspect()
click to toggle source
# File lib/date_named_file/dated_file.rb, line 128 def pretty_inspect "#<#{self.class.to_s}: #{@path}\n @template=#{@dft.template}\n @embedded_date=#{@embedded_date.to_s}\n #{object_id}>" end
to_s()
click to toggle source
# File lib/date_named_file/dated_file.rb, line 120 def to_s @path.to_s end