Class: FileInfo

Inherits:
FileName show all
Defined in:
lib/piggy-core/file_info.rb

Overview

An entity object where you can set all attributes no matter if (or where) the file exists. Next to a name and path it has further attributes such as a creation and a modification time and a size in bytes. New instances aren’t directories by default but you can set this flag, too.

Direct Known Subclasses

CommentedFile

Instance Attribute Summary collapse

Attributes inherited from FileName

#name, #path

Instance Method Summary collapse

Methods inherited from FileName

#extension, #name_with_path, #name_without_extension, #path_sections, #set_path

Constructor Details

#initialize(the_name, the_path = '') ⇒ FileInfo

Returns a new instance of FileInfo.



98
99
100
101
102
# File 'lib/piggy-core/file_info.rb', line 98

def initialize(the_name, the_path = '')
  super(the_name, the_path)
  @size = 0
  @is_directory = false
end

Instance Attribute Details

#ctimeObject

Returns the value of attribute ctime.



96
97
98
# File 'lib/piggy-core/file_info.rb', line 96

def ctime
  @ctime
end

#mtimeObject

Returns the value of attribute mtime.



96
97
98
# File 'lib/piggy-core/file_info.rb', line 96

def mtime
  @mtime
end

#sizeObject

Returns the value of attribute size.



96
97
98
# File 'lib/piggy-core/file_info.rb', line 96

def size
  @size
end

Instance Method Details

#ctime_stringObject



116
117
118
# File 'lib/piggy-core/file_info.rb', line 116

def ctime_string
  time_string_for(ctime)
end

#directory!Object



108
109
110
# File 'lib/piggy-core/file_info.rb', line 108

def directory!
  @is_directory = true
end

#directory?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/piggy-core/file_info.rb', line 104

def directory?
  return @is_directory
end

#mtime_stringObject



112
113
114
# File 'lib/piggy-core/file_info.rb', line 112

def mtime_string
  time_string_for(mtime)
end