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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dirent) ⇒ Stat

Returns a new instance of Stat.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ole/storage/file_system.rb', line 62

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.



60
61
62
# File 'lib/ole/storage/file_system.rb', line 60

def blksize
  @blksize
end

#blocksObject (readonly)

Returns the value of attribute blocks.



60
61
62
# File 'lib/ole/storage/file_system.rb', line 60

def blocks
  @blocks
end

#devObject (readonly)

Returns the value of attribute dev.



61
62
63
# File 'lib/ole/storage/file_system.rb', line 61

def dev
  @dev
end

#ftypeObject (readonly)

Returns the value of attribute ftype.



60
61
62
# File 'lib/ole/storage/file_system.rb', line 60

def ftype
  @ftype
end

#gidObject (readonly)

Returns the value of attribute gid.



61
62
63
# File 'lib/ole/storage/file_system.rb', line 61

def gid
  @gid
end

#inoObject (readonly)

Returns the value of attribute ino.



61
62
63
# File 'lib/ole/storage/file_system.rb', line 61

def ino
  @ino
end

Returns the value of attribute nlink.



61
62
63
# File 'lib/ole/storage/file_system.rb', line 61

def nlink
  @nlink
end

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

Returns the value of attribute rdev.



61
62
63
# File 'lib/ole/storage/file_system.rb', line 61

def rdev
  @rdev
end

#sizeObject (readonly)

Returns the value of attribute size.



60
61
62
# File 'lib/ole/storage/file_system.rb', line 60

def size
  @size
end

#uidObject (readonly)

Returns the value of attribute uid.



61
62
63
# File 'lib/ole/storage/file_system.rb', line 61

def uid
  @uid
end

Instance Method Details

#directory?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/ole/storage/file_system.rb', line 90

def directory?
	@dirent.dir?
end

#file?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/ole/storage/file_system.rb', line 86

def file?
	@dirent.file?
end

#inspectObject



98
99
100
101
102
103
# File 'lib/ole/storage/file_system.rb', line 98

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

#size?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/ole/storage/file_system.rb', line 94

def size?
	size if file?
end