Sha256: acaf45dc154aa19d6b6f9569cc3d91299bfe04a5b47fa253b7e91c82d31a2dc9

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 Bytes

Contents

require "pathname"
require "filetree/simple_tree"

class Pathname
  alias :_parent :parent
  alias :_children :children
end

class FileTree < Pathname
  include SimpleTree

  attr_accessor :name, :id, :identifier

  def name
    @name ||= self.inspect
  end

  def id
    @id ||= self.inspect
  end

  def identifier
    @identifier ||= self.inspect
  end

  #
  # See {http://rubydoc.info/stdlib/pathname/Pathname:parent Pathname.parent}
  #
  # @return [FileTree] The directory immediately above self.
  #
  def parent
    FileTree.new(_parent)
  end

  #
  # See {http://rubydoc.info/stdlib/pathname/Pathname:children Pathname.children}
  #
  # @return [Array] an Array of all entries contained in self.
  #
  def children(*args)
    if self.directory?
      _children(*args)
    else
      []
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
filetree-0.0.3 lib/filetree.rb