module InVFS::Extensions
Constants
- BREAKPOINT_SET
Public Instance Methods
GiB()
click to toggle source
# File lib/invfs/extensions.rb, line 53 def GiB self * (1 << 30) end
KiB()
click to toggle source
# File lib/invfs/extensions.rb, line 45 def KiB self * (1 << 10) end
MiB()
click to toggle source
# File lib/invfs/extensions.rb, line 49 def MiB self * (1 << 20) end
__BREAKHERE__()
click to toggle source
# File lib/invfs/extensions.rb, line 107 def __BREAKHERE__ locate = caller_locations(1, 1)[0] __BREAKPOINT__(locate.path, locate.lineno + 1) end
__BREAKPOINT__(base, pos)
click to toggle source
# File lib/invfs/extensions.rb, line 112 def __BREAKPOINT__(base, pos) case base when Module pos = String(pos.to_sym) when String base = "#{base}".freeze pos = pos.to_i else raise ArgumentError end key = [base, pos] unless BREAKPOINT_SET[key] BREAKPOINT_SET[key] = true DEBUGGER__.break_points.push [true, 0, base, pos] end nil end
__native_file_path?()
click to toggle source
# File lib/invfs/extensions.rb, line 59 def __native_file_path? nil end
clamp(min, max)
click to toggle source
# File lib/invfs/extensions.rb, line 9 def clamp(min, max) case when self < min min when self > max max else self end end
file?(path)
click to toggle source
# File lib/invfs/extensions.rb, line 88 def file?(path) File.file?(File.join(self, path)) end
it_a_file?()
click to toggle source
# File lib/invfs/extensions.rb, line 73 def it_a_file? false end
readat(off, size = nil, buf = "".b)
click to toggle source
# File lib/invfs/extensions.rb, line 96 def readat(off, size = nil, buf = "".b) buf.replace File.binread(self, size, off) buf end
to_i_with_unit()
click to toggle source
# File lib/invfs/extensions.rb, line 29 def to_i_with_unit case strip when /^(\d+(\.\d+)?)(?:([kmg])i?)?b?/i unit = 1 << (10 * " kmgtp".index(($3 || " ").downcase)) ($1.to_f * unit).round else to_i end end