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
| 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
| 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
| 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
| 17 18 19 | # File 'opal/stdlib/pathname.rb', line 17 def relative? !absolute? end | 
#sub(*args) ⇒ Object
| 31 32 33 | # File 'opal/stdlib/pathname.rb', line 31 def sub(*args) Pathname.new(@path.sub(*args)) end | 
#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 |