Sha256: fcfc31b174508654fa4fd21732ec7507c567d77c0de9dc20414162630461dc09

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

class File
  # Use either the browser fs namespace or overriden gem interface.
  `var OPAL_FS = VM.opal.fs;`

  # Converts the given `file_name` into its absolute path. The current working
  # directory is used as the reference unless the `dir_string` is given, in
  # which case that is used.
  #
  # @param [String] file_name
  # @param [String] dir_string
  # @return [String]
  def self.expand_path(file_name, dir_string)
    `return OPAL_FS.expand_path(file_name, dir_string);`
  end

  # Returns a new string constructed by joining the given args with the default
  # file separator.
  #
  # @param [String] str
  # @return [String]
  def self.join(*str)
    `return OPAL_FS.join.apply(OPAL_FS, str);`
  end

  # Returns all the components of the given `file_name` except for the last
  # one.
  #
  # @param [String] file_name
  # @return [String]
  def self.dirname(file_name)
    `return OPAL_FS.dirname(file_name);`
  end

  # Returns the extension of the given filename.
  #
  # @param [String] file_name
  # @return [String]
  def self.extname(file_name)
    `return OPAL_FS.extname(file_name);`
  end

  # Returns the last path component of the given `file_name`. If a suffix is
  # given, and is present in the path, then it is removed. This is useful for
  # removing file extensions, for example.
  #
  # @param [String] file_name
  # @param [String] suffix
  # @return [String]
  def self.basename(file_name, suffix)
    `return OPAL_FS.basename(file_name, suffix);`
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opal-0.3.2 gems/core/lib/core/file.rb
opal-0.3.1 gems/core/lib/core/file.rb
opal-0.3.0 gems/core/lib/core/file.rb