Sha256: 899948158738985609a4765514a4a3058d028108ad3d8f7826f69345738542da
Contents?: true
Size: 575 Bytes
Versions: 2
Compression:
Stored size: 575 Bytes
Contents
# frozen_string_literal: true module Ferver # A representation of Ferver's file list class FileList include Enumerable # Create a new instance with given directory # def initialize(files) @files = files.sort_by { |f| f.name.downcase } end def each(&block) @files.each(&block) end def size @files.size end # Fetch a file by its index # An id out of range with raise FileNotFoundError # def file_by_id(id) @files.at(id) || raise(FileNotFoundError, "File id=#{id} not found") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ferver-1.4.0 | lib/ferver/file_list.rb |
ferver-1.3.1 | lib/ferver/file_list.rb |