Class: ThinOutBackups::Command::File

Inherits:
Pathname
  • Object
show all
Defined in:
lib/thin_out_backups.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ File

Returns a new instance of File.



134
135
136
# File 'lib/thin_out_backups.rb', line 134

def initialize(filename)
  super(Pathname.new(filename))
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



132
133
134
# File 'lib/thin_out_backups.rb', line 132

def file
  @file
end

#filenameObject (readonly)

Returns the value of attribute filename.



132
133
134
# File 'lib/thin_out_backups.rb', line 132

def filename
  @filename
end

Instance Method Details

#full_pathObject



138
139
140
# File 'lib/thin_out_backups.rb', line 138

def full_path
  dirname.to_s + '/' + filename
end

#has_time?Boolean

Returns:

  • (Boolean)


164
# File 'lib/thin_out_backups.rb', line 164

def has_time?; !!time end

#ignored?Boolean

Returns:

  • (Boolean)


165
166
167
168
# File 'lib/thin_out_backups.rb', line 165

def ignored?
  !has_time? or
  ThinOutBackups::Command.ignore_files && filename =~ ThinOutBackups::Command.ignore_files
end

#timeObject



149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/thin_out_backups.rb', line 149

def time
  if ThinOutBackups::Command.get_time_from == :filename
    if filename =~ ThinOutBackups::Command.time_format
      y,m,d, h,i,s = $1,$2,$3, $4,$5,$6
      Time.mktime(y,m,d, h,i,s)
    else
      nil
    end
  elsif ThinOutBackups::Command.get_time_from == :file_system
    file.mtime
  else
    raise "Unknown value for #{ThinOutBackups::Command.get_time_from}"
  end
end

#to_sObject



145
146
147
# File 'lib/thin_out_backups.rb', line 145

def to_s
  filename
end