Class: Pathname

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

Overview

ByteSize adds two new methods to the Pathname class:

  • #bytesize

  • #bytesize?

Plus the equivalent methods for IECByteSize:

  • #iecbytesize

  • #iecbytesize?

Instance Method Summary collapse

Instance Method Details

#bytesizeObject

:call-seq:

bytesize  ->  bytesize

Identical to #size[https://ruby-doc.org/stdlib/libdoc/pathname/rdoc/Pathname.html#method-i-size] except that the value is returned as an instance of ByteSize.



1230
1231
1232
# File 'lib/bytesize.rb', line 1230

def bytesize
	ByteSize.new(size)
end

#bytesize?Boolean

:call-seq:

bytesize?  ->  bytesize or nil

Identical to #size?[https://ruby-doc.org/stdlib/libdoc/pathname/rdoc/Pathname.html#method-i-size-3F] except that the value is returned as an instance of ByteSize.

Returns:

  • (Boolean)


1243
1244
1245
1246
# File 'lib/bytesize.rb', line 1243

def bytesize?
	sz = size?
	sz.nil? ? nil : ByteSize.new(sz)
end

#iecbytesizeObject

:call-seq:

iecbytesize  ->  bytesize

Identical to #size[https://ruby-doc.org/stdlib/libdoc/pathname/rdoc/Pathname.html#method-i-size] except that the value is returned as an instance of IECByteSize.



1257
1258
1259
# File 'lib/bytesize.rb', line 1257

def iecbytesize
	IECByteSize.new(size)
end

#iecbytesize?Boolean

:call-seq:

iecbytesize?  ->  bytesize or nil

Identical to #size?[https://ruby-doc.org/stdlib/libdoc/pathname/rdoc/Pathname.html#method-i-size-3F] except that the value is returned as an instance of IECByteSize.

Returns:

  • (Boolean)


1270
1271
1272
1273
# File 'lib/bytesize.rb', line 1270

def iecbytesize?
	sz = size?
	sz.nil? ? nil : IECByteSize.new(sz)
end