Class: Pathname

Inherits:
Object show all
Defined in:
opal/stdlib/pathname.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Pathname

Returns a new instance of Pathname

Raises:

  • (ArgumentError)


2
3
4
5
# File 'opal/stdlib/pathname.rb', line 2

def initialize path
  raise ArgumentError if path == "\0"
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path



7
8
9
# File 'opal/stdlib/pathname.rb', line 7

def path
  @path
end

Instance Method Details

#==(other) ⇒ Object



9
10
11
# File 'opal/stdlib/pathname.rb', line 9

def == other
  other.path == @path
end

#absolute?Boolean

Returns:



13
14
15
# File 'opal/stdlib/pathname.rb', line 13

def absolute?
  @path.start_with? '/'
end

#relative?Boolean

Returns:



17
18
19
# File 'opal/stdlib/pathname.rb', line 17

def relative?
  !absolute?
end

#to_pathObject Also known as: to_str, to_s



21
22
23
# File 'opal/stdlib/pathname.rb', line 21

def to_path
  @path
end