Class: Pathname

Inherits:
Object show all
Defined in:
lib/ruby/pathname.rb

Instance Method Summary collapse

Instance Method Details

#child_of?(p2) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/ruby/pathname.rb', line 8

def child_of?(p2)
  expand_path.to_s.include?(p2.expand_path.to_s)
end

#hidden?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby/pathname.rb', line 16

def hidden?
  path = expand_path

  until path.root?
    return true if path.basename.to_s.start_with? "."
    path = path.parent
  end

  false
end

#to_urlObject



12
13
14
# File 'lib/ruby/pathname.rb', line 12

def to_url
  java.io.File.new(to_s).to_url.to_s
end

#touch(path) ⇒ Object



2
3
4
5
6
# File 'lib/ruby/pathname.rb', line 2

def touch(path)
  file = self + path
  file.open("w+") { nil } unless file.exist?
  file
end