Sha256: fdad2a8ece543105a06ba63d18a112fa7bbebf748e5731c5392e8d5bc4331ced

Contents?: true

Size: 752 Bytes

Versions: 21

Compression:

Stored size: 752 Bytes

Contents

class Pathname
  def initialize(path)
    raise ArgumentError if path == "\0"
    @path = path
  end

  attr_reader :path

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

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

  def relative?
    !absolute?
  end

  def root?
    @path == '/'
  end

  def parent
    new_path = @path.sub(%r{/([^/]+/?$)}, '')
    new_path = absolute? ? '/' : '.' if new_path == ''
    Pathname.new(new_path)
  end

  def sub(*args)
    Pathname.new(@path.sub(*args))
  end

  def cleanpath
    `return Opal.normalize_loadable_path(#@path)`
  end

  def to_path
    @path
  end

  def hash
    @path
  end

  alias :to_str :to_path
  alias :to_s :to_path
end

module Kernel
  def Pathname(path)
    Pathname.new(path)
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
opal-0.9.4 stdlib/pathname.rb
opal-0.9.3 stdlib/pathname.rb
opal-0.9.2 stdlib/pathname.rb
opal-0.9.0 stdlib/pathname.rb
opal-0.9.0.rc1 stdlib/pathname.rb
opal-0.9.0.beta2 stdlib/pathname.rb
opal-0.9.0.beta1 stdlib/pathname.rb
opal-0.8.1 stdlib/pathname.rb
opal-0.8.1.rc1 stdlib/pathname.rb
opal-wedge-0.9.0.dev stdlib/pathname.rb
opal-0.8.0 stdlib/pathname.rb
opal-0.8.0.rc3 stdlib/pathname.rb
opal-0.8.0.rc2 stdlib/pathname.rb
opal-0.8.0.rc1 stdlib/pathname.rb
opal-0.8.0.beta1 stdlib/pathname.rb
opal-0.7.2 stdlib/pathname.rb
opal-0.7.1 stdlib/pathname.rb
opal-0.7.0 stdlib/pathname.rb
opal-0.7.0.rc1 stdlib/pathname.rb
opal-0.7.0.beta3 stdlib/pathname.rb