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

#absoluteString (readonly) Also known as: a

Returns:



229
230
231
# File 'lib/tagen/core/pa/path.rb', line 229

def absolute
  @absolute
end

#baseString (readonly) Also known as: b

Returns:



229
230
231
# File 'lib/tagen/core/pa/path.rb', line 229

def base
  @base
end

#dirString (readonly) Also known as: d

Returns:



229
230
231
# File 'lib/tagen/core/pa/path.rb', line 229

def dir
  @dir
end

#extString (readonly) Also known as: e

Returns:



229
230
231
# File 'lib/tagen/core/pa/path.rb', line 229

def ext
  @ext
end

#fextString (readonly) Also known as: fe

Returns:



229
230
231
# File 'lib/tagen/core/pa/path.rb', line 229

def fext
  @fext
end

#nameString (readonly) Also known as: n

Returns:



229
230
231
# File 'lib/tagen/core/pa/path.rb', line 229

def name
  @name
end

#shortString (readonly)

Returns:



229
230
231
# File 'lib/tagen/core/pa/path.rb', line 229

def short
  @short
end

Instance Method Details

#+(str) ⇒ Pa

add string to path

Examples:

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

Parameters:

Returns:



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

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

#==(other) ⇒ Object



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

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

#=~(regexp) ⇒ Object



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

def =~(regexp) path =~ regexp end

#absolute_pathPa

Returns absolute path.

Returns:

  • (Pa)

    absolute path



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

def absolute_path() Pa(absolute) end

#dirnamePa

Returns dirname.

Examples:

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

Returns:

  • (Pa)

    dirname



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

def dirname() Pa(dir) end

#end_with?(*args) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#gsub(*args, &blk) ⇒ Pa

Returns:



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

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

#gsub!(*args, &blk) ⇒ Pa

Returns:



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

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

#initialize_variablesObject



231
232
233
234
235
236
237
238
239
# File 'lib/tagen/core/pa/path.rb', line 231

def initialize_variables
	super
	@absolute = Pa.absolute(@path) 
	@dir = Pa.dirname(@path)
	@base = Pa.basename(@path) 
	@name, @ext = Pa.basename(@path, ext: true)
	@fext = @ext.empty? ? "" : "."+@ext
	@short = Pa.shorten(@path) 
end

#match(*args, &blk) ⇒ MatchData

Returns:



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

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

#start_with?(*args) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#sub(*args, &blk) ⇒ Pa

Returns:



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

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

#sub!(*args, &blk) ⇒ Pa

Returns:



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

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