Class: Pathname
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #absolute? ⇒ Boolean
- #cleanpath ⇒ Object
- #hash ⇒ Object
-
#initialize(path) ⇒ Pathname
constructor
A new instance of Pathname.
- #parent ⇒ Object
- #relative? ⇒ Boolean
- #root? ⇒ Boolean
- #sub(*args) ⇒ Object
- #to_path ⇒ Object (also: #to_str, #to_s)
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
#path ⇒ Object (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:
- (Boolean )
13 14 15
# File 'opal/stdlib/pathname.rb', line 13 def absolute? @path.start_with? '/' end
#cleanpath ⇒ Object
35 36 37
# File 'opal/stdlib/pathname.rb', line 35 def cleanpath `return Opal.normalize_loadable_path(#@path)` end
#hash ⇒ Object
43 44 45
# File 'opal/stdlib/pathname.rb', line 43 def hash @path end
#parent ⇒ Object
#relative? ⇒ Boolean
Returns:
- (Boolean )
17 18 19
# File 'opal/stdlib/pathname.rb', line 17 def relative? !absolute? end
#root? ⇒ Boolean
Returns:
- (Boolean )
21 22 23
# File 'opal/stdlib/pathname.rb', line 21 def root? @path == '/' end
#sub(*args) ⇒ Object
#to_path ⇒ Object Also known as: to_str, to_s
39 40 41
# File 'opal/stdlib/pathname.rb', line 39 def to_path @path end