Class: Pathname

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

Instance Method Summary collapse

Instance Method Details

#_original_subObject



18
# File 'lib/nrser/core_ext/pathname.rb', line 18

alias_method :_original_sub, :sub

#find_up(rel_path, **kwds) ⇒ return_type

TODO:

Document find_root method.

Returns @todo Document return value.

Parameters:

  • arg_name (type)

    @todo Add name param description.

Returns:

  • (return_type)

    @todo Document return value.



60
61
62
# File 'lib/nrser/core_ext/pathname.rb', line 60

def find_up rel_path, **kwds
  NRSER.find_up rel_path, **kwds, from: self
end

#find_up!(rel_path, **kwds) ⇒ return_type

TODO:

Document find_root method.

Returns @todo Document return value.

Parameters:

  • arg_name (type)

    @todo Add name param description.

Returns:

  • (return_type)

    @todo Document return value.



73
74
75
# File 'lib/nrser/core_ext/pathname.rb', line 73

def find_up! rel_path, **kwds
  NRSER.find_up! rel_path, **kwds, from: self
end

#start_with?(*prefixes) ⇒ Boolean

override to accept Pathname instances.

Parameters:

  • *prefixes (String)

    the prefixes to see if the Pathname starts with.

Returns:

  • (Boolean)

    true if the Pathname starts with any of the prefixes.



13
14
15
# File 'lib/nrser/core_ext/pathname.rb', line 13

def start_with? *prefixes
  to_s.start_with? *prefixes.map(&:to_s)
end

#sub(pattern, replacement) ⇒ Pathname

override sub to support Pathname instances as patterns.

Parameters:

Returns:



32
33
34
35
36
37
38
39
# File 'lib/nrser/core_ext/pathname.rb', line 32

def sub pattern, replacement
  case pattern
  when Pathname
    _original_sub pattern.to_s, replacement
  else
    _original_sub pattern, replacement
  end
end

#to_pnPathname

Just returns ‘self`. Implemented to match the String#to_pn API so it can be called on an argument that may be either one.

Returns:



47
48
49
# File 'lib/nrser/core_ext/pathname.rb', line 47

def to_pn
  self
end