Sha256: 1e72f67190e1e9d320bdd1c6622a3fecc004721ba44b92b2021cd87f1bca726d

Contents?: true

Size: 620 Bytes

Versions: 2

Compression:

Stored size: 620 Bytes

Contents

module Ro
  class Root < ::String
    def initialize(root)
      super(Ro.realpath(root.to_s))
    ensure
      raise ArgumentError.new("root=#{ root.inspect }") if root.nil?
      raise ArgumentError.new("root=#{ root.inspect }") unless test(?d, root)
    end

    def root
      self
    end

    def nodes
      Node::List.new(root) do |list|
        node_directories do |path|
          list.load(path)
        end
      end
    end

    def directories(&block)
      Dir.glob(File.join(root, '*/'), &block)
    end

    def node_directories(&block)
      Dir.glob(File.join(root, '*/*/'), &block)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ro-1.1.1 lib/ro/root.rb
ro-1.1.0 lib/ro/root.rb