Sha256: 6d304a22f7b85f219c651a0f8d4b52880732bf084f4c1d98ca8fe9a0d3d05caa

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

module Ro
  class Db
    class Collection
      class List < ::Array
        def add(path)
          name = File.basename(path.to_s)

          unless any?{|c| c.name == name }
            collection = Collection.new(path)
            push(collection)
            sort!{|a,b| a.name <=> b.name}
          end
        end
      end

      fattr :path

      def initialize(path)
        @path = Util.realpath(path)
      end

      def basename
        File.basename(@path)
      end

      def name
        basename
      end

      def dirname
        File.dirname(@path)
      end

      def glob
        File.join(@path, '*')
      end

      def nodes
        Dir.glob(glob).map do |path|
          next unless test(?d, path)
          Ro::Node.new(path)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ro-1.0.0 lib/ro/db/collection.rb