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/cmd.rb,
lib/tagen/core/pa/dir.rb,
lib/tagen/core/pa/path.rb,
lib/tagen/core/pa/path.rb,
lib/tagen/core/pa/state.rb

Overview

ls family

* Dir _support globbing_ * Pa.glob(*path,o),(){} _support globbing with option and block_ * each(path),(){} each_r(),(){} _support Enumerator. not support globbing_ * ls(path) ls_r(path) _sample ls. not support globbing._

Example

each(“.”) do |pa| p pa end

each(“.”).with_index(2){|pa,i| … }

Defined Under Namespace

Modules: ClassMethods, Path, State

Constant Summary collapse

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::Path

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

Methods included from ClassMethods::Dir

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

Methods included from ClassMethods::State

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

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 State

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

Methods included from Path

#+, #==, #=~, #absolute_path, #dirname, #end_with?, #gsub, #gsub!, #initialize_variables, #match, #start_with?, #sub, #sub!

Constructor Details

#initialize(path) ⇒ Pa

Returns a new instance of Pa.

Parameters:



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

#method_missing(name, *args, &blk) ⇒ Object

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

#pathObject (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

#inspectString

return ‘#<Pa @path=“foo”, @absolute=“/home/foo”>’

Returns:



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

#replace(path) ⇒ Pa

Returns the same Pa object.

Parameters:

Returns:

  • (Pa)

    the same Pa object



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

#to_sString

return ‘/home/foo’

Returns:



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

def to_s
	@path
end