Class: Ole::Storage::FileClass::Stat

Inherits:
Object
  • Object
show all
Defined in:
lib/ole/file_system.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dirent) ⇒ Stat

Returns a new instance of Stat.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/ole/file_system.rb', line 82

def initialize dirent
  @dirent = dirent
  @size = dirent.size
  if file?
    @ftype = 'file'
    bat = dirent.ole.bat_for_size(dirent.size)
    @blocks = bat.chain(dirent.first_block).length
    @blksize = bat.block_size
  else
    @ftype = 'directory'
    @blocks = 0
    @blksize = 0
  end
  # a lot of these are bogus. ole file format has no analogs
  @nlink = 1
  @uid, @gid = 0, 0
  @dev, @rdev = 0, 0
  @ino = 0
  # need to add times - atime, mtime, ctime. 
end

Instance Attribute Details

#blksizeObject (readonly)

Returns the value of attribute blksize.



80
81
82
# File 'lib/ole/file_system.rb', line 80

def blksize
  @blksize
end

#blocksObject (readonly)

Returns the value of attribute blocks.



80
81
82
# File 'lib/ole/file_system.rb', line 80

def blocks
  @blocks
end

#devObject (readonly)

Returns the value of attribute dev.



81
82
83
# File 'lib/ole/file_system.rb', line 81

def dev
  @dev
end

#ftypeObject (readonly)

Returns the value of attribute ftype.



80
81
82
# File 'lib/ole/file_system.rb', line 80

def ftype
  @ftype
end

#gidObject (readonly)

Returns the value of attribute gid.



81
82
83
# File 'lib/ole/file_system.rb', line 81

def gid
  @gid
end

#inoObject (readonly)

Returns the value of attribute ino.



81
82
83
# File 'lib/ole/file_system.rb', line 81

def ino
  @ino
end

Returns the value of attribute nlink.



81
82
83
# File 'lib/ole/file_system.rb', line 81

def nlink
  @nlink
end

#rdevObject (readonly) Also known as: rdev_major, rdev_minor

Returns the value of attribute rdev.



81
82
83
# File 'lib/ole/file_system.rb', line 81

def rdev
  @rdev
end

#sizeObject (readonly)

Returns the value of attribute size.



80
81
82
# File 'lib/ole/file_system.rb', line 80

def size
  @size
end

#uidObject (readonly)

Returns the value of attribute uid.



81
82
83
# File 'lib/ole/file_system.rb', line 81

def uid
  @uid
end

Instance Method Details

#directory?Boolean

Returns:



110
111
112
# File 'lib/ole/file_system.rb', line 110

def directory?
  @dirent.dir?
end

#file?Boolean

Returns:



106
107
108
# File 'lib/ole/file_system.rb', line 106

def file?
  @dirent.file?
end

#inspectObject



114
115
116
117
118
119
# File 'lib/ole/file_system.rb', line 114

def inspect
  pairs = (instance_variables - ['@dirent']).map do |n|
    "#{n[1..-1]}=#{instance_variable_get n}"
  end
  "#<#{self.class} #{pairs * ', '}>"
end