[フレーム]

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

#cleanpathObject

35
36
37
# File 'opal/stdlib/pathname.rb', line 35
def cleanpath
 `return Opal.normalize_loadable_path(#@path)`
end

#hashObject

43
44
45
# File 'opal/stdlib/pathname.rb', line 43
def hash
 @path
end

#parentObject

25
26
27
28
29
# File 'opal/stdlib/pathname.rb', line 25
def parent
 new_path = @path.sub(%r{/([^/]+/?$)}, '')
 new_path = absolute? ? '/' : '.' if new_path == ''
 Pathname .new (new_path)
end

#relative?Boolean

Returns:

17
18
19
# File 'opal/stdlib/pathname.rb', line 17
def relative?
 !absolute?
end

#root?Boolean

Returns:

21
22
23
# File 'opal/stdlib/pathname.rb', line 21
def root?
 @path == '/'
end

#sub(*args) ⇒ Object

31
32
33
# File 'opal/stdlib/pathname.rb', line 31
def sub(*args)
 Pathname .new (@path.sub(*args))
end

#to_pathObject Also known as: to_str, to_s

39
40
41
# File 'opal/stdlib/pathname.rb', line 39
def to_path
 @path
end

AltStyle によって変換されたページ (->オリジナル) /