Module: Pa::Path

Included in:
Pa
Defined in:
lib/tagen/core/pa/path.rb

Overview

attribute absolute and dir return String, method absolute_path(), dirname() return Pa Pa("/home/a").dir #=> "/home" Pa("/home/a").dirname #=> Pa("/home")

methods from String

  • +

  • g]sub[!

    match =~

  • start_with? end_with?

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (String) absolute (readonly) Also known as: a

Returns:



232
233
234
# File 'lib/tagen/core/pa/path.rb', line 232

def absolute
  @absolute
end

- (String) base (readonly) Also known as: b

Returns:



232
233
234
# File 'lib/tagen/core/pa/path.rb', line 232

def base
  @base
end

- (String) dir (readonly) Also known as: d

Returns:



232
233
234
# File 'lib/tagen/core/pa/path.rb', line 232

def dir
  @dir
end

- (String) ext (readonly) Also known as: e

Returns:



232
233
234
# File 'lib/tagen/core/pa/path.rb', line 232

def ext
  @ext
end

- (String) fext (readonly) Also known as: fe

Returns:



232
233
234
# File 'lib/tagen/core/pa/path.rb', line 232

def fext
  @fext
end

- (String) name (readonly) Also known as: n

Returns:



232
233
234
# File 'lib/tagen/core/pa/path.rb', line 232

def name
  @name
end

- (String) short (readonly)

Returns:



232
233
234
# File 'lib/tagen/core/pa/path.rb', line 232

def short
	@short ||= Pa.shorten(@path) 
end

Instance Method Details

- (Pa) +(str)

add string to path

Examples:

pa = Pa('/home/foo/a.txt')
pa+'~' #=> new Pa('/home/foo/a.txt~')

Parameters:

Returns:



271
# File 'lib/tagen/core/pa/path.rb', line 271

def +(str) Pa(path+str) end

- (Object) ==(other)



296
# File 'lib/tagen/core/pa/path.rb', line 296

def ==(other) self.path == other.path end

- (Object) =~(regexp)



294
# File 'lib/tagen/core/pa/path.rb', line 294

def =~(regexp) path =~ regexp end

- (Pa) absolute2

Absolute path

Returns:

  • (Pa)

    absolute path



256
# File 'lib/tagen/core/pa/path.rb', line 256

def absolute2() @absolute2 ||= Pa(absolute) end

- (Pa) dir2

Dirname

Examples:

Pa(__FILE__).dirname.join('.opts')

Returns:

  • (Pa)

    dirname



261
# File 'lib/tagen/core/pa/path.rb', line 261

def dir2() @dir2 ||= Pa(dir) end

- (Boolean) end_with?(*args)

Returns:

  • (Boolean)


292
# File 'lib/tagen/core/pa/path.rb', line 292

def end_with?(*args) path.end_with?(*args) end

- (Pa) gsub(*args, &blk)

Returns:



277
# File 'lib/tagen/core/pa/path.rb', line 277

def gsub(*args,&blk) Pa(path.gsub(*args,&blk)) end

- (Pa) gsub!(*args, &blk)

Returns:



283
# File 'lib/tagen/core/pa/path.rb', line 283

def gsub!(*args,&blk) self.replace path.gsub(*args,&blk) end

- (Object) initialize_variables



234
235
236
237
238
239
240
241
242
# File 'lib/tagen/core/pa/path.rb', line 234

def initialize_variables
	super
	@absolute = File.absolute_path(@path) 
	@dir = File.dirname(@path)
	@base = File.basename(@path) 
	@name, @ext = @base.match(NAME_EXT_PAT).captures
	@ext ||= ""
	@fext = @ext.empty? ? "" : "."+@ext
end

- (MatchData) match(*args, &blk)

Returns:



286
# File 'lib/tagen/core/pa/path.rb', line 286

def match(*args,&blk) path.match(*args,&blk) end

- (Boolean) start_with?(*args)

Returns:

  • (Boolean)


289
# File 'lib/tagen/core/pa/path.rb', line 289

def start_with?(*args) path.start_with?(*args) end

- (Pa) sub(*args, &blk)

Returns:



274
# File 'lib/tagen/core/pa/path.rb', line 274

def sub(*args,&blk) Pa(path.sub(*args,&blk)) end

- (Pa) sub!(*args, &blk)

Returns:



280
# File 'lib/tagen/core/pa/path.rb', line 280

def sub!(*args,&blk) self.replace path.sub(*args,&blk) end