Sha256: 06bbd86fe95fbaff20e7bd086788cc0284854c6661b4d38a3f64b625aa32409c

Contents?: true

Size: 610 Bytes

Versions: 7

Compression:

Stored size: 610 Bytes

Contents

module Mireru
  class Container
    def initialize(files=[])
      @files = files.select {|file| file?(file) }
    end

    def empty?
      @files.empty?
    end

    def size
      @files.size
    end

    def pop(complement_file=nil)
      @files.unshift(complement_file) if complement_file
      @files.pop
    end

    def shift(complement_file=nil)
      @files.push(complement_file) if complement_file
      @files.shift
    end

    private
    def file?(file)
      unless file
        return false
      end

      unless File.file?(file)
        return false
      end

      true
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mireru-0.2.1 lib/mireru/container.rb
mireru-0.2.0 lib/mireru/container.rb
mireru-0.1.9 lib/mireru/container.rb
mireru-0.1.8 lib/mireru/container.rb
mireru-0.1.7 lib/mireru/container.rb
mireru-0.1.6 lib/mireru/container.rb
mireru-0.1.5 lib/mireru/container.rb