Module: RIO::Ops::FileOrDir::Existing

Includes:
ExistOrNot
Included in:
Dir::Existing, Dir::Stream, RIO::Ops::File::Existing
Defined in:
lib/rio/ops/either.rb

Instance Method Summary collapse

Instance Method Details

#basename=(arg) ⇒ Object



95
96
97
# File 'lib/rio/ops/either.rb', line 95

def basename=(arg)
  rename!(_path_with_basename(arg))
end

#chmod(mod) ⇒ Object



65
# File 'lib/rio/ops/either.rb', line 65

def chmod(mod) rtn_self { fs.chmod(mod,fspath) } end

#chown(owner, group) ⇒ Object



66
# File 'lib/rio/ops/either.rb', line 66

def chown(owner,group) rtn_self { fs.chown(owner,group,fspath) } end

#dirname=(arg) ⇒ Object



105
106
107
# File 'lib/rio/ops/either.rb', line 105

def dirname=(arg)
  rename!(_path_with_dirname(arg))
end

#empty?Boolean

Returns:

  • (Boolean)


127
# File 'lib/rio/ops/either.rb', line 127

def empty?() self.to_a.empty? end

#extname=(ex) ⇒ Object



101
102
103
104
# File 'lib/rio/ops/either.rb', line 101

def extname=(ex)
  rename!(_path_with_ext(ex))
  cx['ext'] = ex
end

#filename=(arg) ⇒ Object



98
99
100
# File 'lib/rio/ops/either.rb', line 98

def filename=(arg)
  rename!(_path_with_filename(arg))
end

#mountpoint?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/rio/ops/either.rb', line 124

def mountpoint?
  fs.mountpoint?(fspath)
end

#must_existObject



67
# File 'lib/rio/ops/either.rb', line 67

def must_exist() self end

#realpathObject



121
122
123
# File 'lib/rio/ops/either.rb', line 121

def realpath
  new_rio(fs.realpath(fspath))
end

#rename(*args, &block) ⇒ Object Also known as: mv



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rio/ops/either.rb', line 69

def rename(*args,&block)
  if args.empty?
    softreset.rename(*args,&block)
  else
    rtn_reset { 
      dst = ensure_rio(args.shift)
      #p "rename: #{self} => #{dst}"
      fs.mv(self,dst,*args) 
      dst.reset
    } 
  end
end

#rename!(*args, &block) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rio/ops/either.rb', line 81

def rename!(*args,&block)
  if args.empty?
    softreset.rename(*args,&block)
  else
    rtn_reset { 
      dst = ensure_rio(args.shift)
      #p "rename!: #{self} => #{dst}"
      fs.mv(self,dst,*args) unless self == dst 
      dst.reset
      self.rl = dst.rl.clone
    } 
  end
end

#ss_type?Boolean

Returns:

  • (Boolean)


109
110
111
112
113
114
115
116
117
118
# File 'lib/rio/ops/either.rb', line 109

def ss_type?
  case cx['ss_type']
  when nil
    'entries'
  when 'files', 'dirs', 'entries', 'skipfiles', 'skipdirs', 'skipentries'
    cx['ss_type'] 
  else
    nil
  end
end