Class: Pa
- Extended by:
- ClassMethods, ClassMethods::Cmd, ClassMethods::Dir, ClassMethods::Path, ClassMethods::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
Instance Attribute Summary collapse
-
#path ⇒ Object
(also: #p)
readonly
Returns the value of attribute path.
Attributes included from Path
#absolute, #base, #dir, #ext, #fext, #name, #short
Instance Method Summary collapse
-
#initialize(path) ⇒ Pa
constructor
A new instance of Pa.
-
#inspect ⇒ String
return ‘#<Pa @path=“foo”, @absolute=“/home/foo”>’.
-
#method_missing(name, *args, &blk) ⇒ Object
missing method goes to Pa.class-method.
-
#replace(path) ⇒ Pa
The same Pa object.
-
#to_s ⇒ String
return ‘/home/foo’.
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.
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
#path ⇒ Object (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
#inspect ⇒ String
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 |
#replace(path) ⇒ Pa
Returns 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_s ⇒ String
return ‘/home/foo’
102 103 104 |
# File 'lib/tagen/core/pa.rb', line 102 def to_s @path end |