Class: Pa

Inherits:
Object show all
Extended by:
ClassMethods, ClassMethods::Cmd, ClassMethods::Dir, ClassMethods::Path, ClassMethods::State
Includes:
Path, State
Defined in:
lib/tagen/core/pa.rb,
lib/tagen/core/pa.rb,
lib/tagen/core/pa.rb,
lib/tagen/core/pa/dir.rb,
lib/tagen/core/pa/cmd.rb,
lib/tagen/core/pa/path.rb,
lib/tagen/core/pa/path.rb,
lib/tagen/core/pa/state.rb

Overview

rm family * rm _rm file only_ * rmdir _rm directory only_ * rm_r _rm recurive, both file and directory_ * rm_if _with condition, use rm_r_

Example

rm path # it's clear: remove a file
rmdir path #  it's clear: remove a directory

Defined Under Namespace

Modules: ClassMethods, Path, State

Constant Summary

Error =
Class.new Exception
EUnkonwType =
Class.new Error
NAME_EXT_PAT =
/^(.+?)(?:\.([^.]+))?$/

Constants included from ClassMethods

ClassMethods::UNDEFS

Instance Attribute Summary (collapse)

Attributes included from Path

#absolute, #base, #dir, #ext, #fext, #name, #short

Instance Method Summary (collapse)

Methods included from ClassMethods::Cmd

chroot, cp, home, mkdir, mkdir_f, mktmpdir, mktmpfile, mv, rm, rm_if, rm_r, rmdir, touch, touch_f

Methods included from ClassMethods::State

chmod, chown, lchmod, lchown, mountpoint?, type, utime

Methods included from ClassMethods::Dir

each, each_r, empty?, glob, ls, ls_r

Methods included from ClassMethods::Path

absolute, absolute?, basename, cd, dangling?, expand, extname, get, join, ln, ln_f, parent, pwd, pwd2, readlink, realpath, shorten, split, symln, symln_f

Methods included from State

#chmod, #chown, #lchmod, #lchown, #utime

Methods included from Path

#+, #==, #=~, #absolute2, #dir2, #end_with?, #gsub, #gsub!, #initialize_variables, #match, #start_with?, #sub, #sub!

Constructor Details

- (Pa) initialize(path)



70
71
72
73
# File 'lib/tagen/core/pa.rb', line 70

def initialize path
	@path = path.respond_to?(:path) ? path.path : path
	initialize_variables
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(name, *args, &blk)

missing method goes to Pa.class-method



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/tagen/core/pa.rb', line 107

def method_missing(name, *args, &blk)
	ret = self.class.__send__(name, path, *args, &blk)

	case ret	

	# e.g. readlink ..
	when String
		Pa(ret)

	# e.g. directory? 
	else
		ret
	end

end

Instance Attribute Details

- (Object) path (readonly) Also known as: p

Returns the value of attribute path



67
68
69
# File 'lib/tagen/core/pa.rb', line 67

def path
  @path
end

Instance Method Details

- (String) inspect

return '#<Pa @path="foo", @absolute="/home/foo">'



92
93
94
95
96
97
# File 'lib/tagen/core/pa.rb', line 92

def inspect
	ret="#<" + self.class.to_s + " "
	ret += "@path=\"#{path}\", @absolute=\"#{absolute}\""
	ret += " >"
	ret
end

- (Pa) replace(path)



84
85
86
87
# File 'lib/tagen/core/pa.rb', line 84

def replace path
	@path = path.respond_to?(:path) ? path.path : path
	initialize_variables
end

- (String) to_s

return '/home/foo'



102
103
104
# File 'lib/tagen/core/pa.rb', line 102

def to_s
	@path
end