Class: RelPathname

Inherits:
Pathname show all
Defined in:
lib/relpathname.rb

Instance Method Summary collapse

Constructor Details

#initialize(p1) ⇒ RelPathname



12
13
14
15
16
# File 'lib/relpathname.rb', line 12

def initialize p1
    @initial_pwd = Pathname.pwd

    super p1
end

Instance Method Details

#+(p1) ⇒ Object



32
33
34
# File 'lib/relpathname.rb', line 32

def + p1
    RelPathname.new to_pn + p1
end

#/(p) ⇒ Object



36
37
38
# File 'lib/relpathname.rb', line 36

def / p
    RelPathname.new to_pn + p
end

#<=>(p1) ⇒ Object



40
41
42
# File 'lib/relpathname.rb', line 40

def <=> p1
    to_pn <=> p1
end

#==(p1) ⇒ Object



44
45
46
# File 'lib/relpathname.rb', line 44

def == p1
    to_pn == p1
end

#===(p1) ⇒ Object



48
49
50
# File 'lib/relpathname.rb', line 48

def === p1
    to_pn === p1
end

#absolute?Boolean



52
53
54
# File 'lib/relpathname.rb', line 52

def absolute?
    to_pn.absolute?
end

#basenameObject



56
57
58
# File 'lib/relpathname.rb', line 56

def basename
    RelPathname.new to_pn.basename
end

#children(*args) ⇒ Object



60
61
62
# File 'lib/relpathname.rb', line 60

def children *args
    to_pn.children(*args).map do |path| RelPathname.new path end
end

#cleanpath(*args) ⇒ Object



64
65
66
# File 'lib/relpathname.rb', line 64

def cleanpath *args
    RelPathname.new to_pn.cleanpath(*args)
end

#directory?Boolean



68
69
70
# File 'lib/relpathname.rb', line 68

def directory?
    to_pn.directory?
end

#dirnameObject



72
73
74
# File 'lib/relpathname.rb', line 72

def dirname
    RelPathname.new to_pn.dirname
end

#executable?Boolean



76
77
78
# File 'lib/relpathname.rb', line 76

def executable?
    to_pn.executable?
end

#executable_real?Boolean



80
81
82
# File 'lib/relpathname.rb', line 80

def executable_real?
    to_pn.executable_real?
end

#extnameObject



84
85
86
# File 'lib/relpathname.rb', line 84

def extname
    RelPathname.new to_pn.extname
end

#file?Boolean



88
89
90
# File 'lib/relpathname.rb', line 88

def file?
    to_pn.file?
end

#mkpathObject



92
93
94
# File 'lib/relpathname.rb', line 92

def mkpath
    RelPathname.new to_pn.mkpath
end

#mtimeObject



96
97
98
# File 'lib/relpathname.rb', line 96

def mtime
    to_pn.mtime
end

#parentObject



100
101
102
# File 'lib/relpathname.rb', line 100

def parent
    RelPathname.new to_pn.parent
end

#relative?Boolean



104
105
106
# File 'lib/relpathname.rb', line 104

def relative?
    to_pn.relative?
end

#symlink?Boolean



108
109
110
# File 'lib/relpathname.rb', line 108

def symlink?
    to_pn.symlink?
end

#to_pathObject



22
23
24
# File 'lib/relpathname.rb', line 22

def to_path
    (@initial_pwd + super).relative_path_from(Pathname.pwd).to_s
end

#to_pnObject



18
19
20
# File 'lib/relpathname.rb', line 18

def to_pn
    Pathname.new to_path
end

#to_sObject



27
28
29
30
# File 'lib/relpathname.rb', line 27

def to_s
    prefix = to_pn.each_filename.to_a[0] == '..' ? '' : './'
    prefix + to_path
end