class DirFriend::F

Attributes

level[R]
name[R]
path[R]
stat[R]

Public Class Methods

new(name, level:0) click to toggle source
# File lib/dir_friend/f.rb, line 5
def initialize(name, level:0)
  @path = File.expand_path(name)
  @name = File.basename(@path)
  @stat = File.lstat(@path)
  @level = level
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/dir_friend/f.rb, line 23
def <=>(other)
  self.name <=> other.name
end
==(other) click to toggle source
# File lib/dir_friend/f.rb, line 18
def ==(other)
  self.path == other.path
end
Also aliased as: eql?
eql?(other)
Alias for: ==
info() click to toggle source
# File lib/dir_friend/f.rb, line 27
def info
  format = %i(mode nlink uid gid size mtime)
  arr = format.map { |attr| [attr, stat.send(attr)] }
  Hash[ arr ]
end
method_missing(name, *a, &b) click to toggle source
Calls superclass method
# File lib/dir_friend/f.rb, line 12
def method_missing(name, *a, &b)
  stat_methods = stat.class.instance_methods(false)
  return super unless stat_methods.include?(name)
  stat.__send__(name)
end
to_s() click to toggle source
# File lib/dir_friend/f.rb, line 33
def to_s
  "F: #{name}"
end