Class: Makimono::ResourceList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/makimono/resource_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resources) ⇒ ResourceList

Returns a new instance of ResourceList.



22
23
24
# File 'lib/makimono/resource_list.rb', line 22

def initialize(resources)
  @resources = resources
end

Class Method Details

.from_dir(dir) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/makimono/resource_list.rb', line 9

def self.from_dir(dir)
  raise InvalidSourceError, "Source directory `#{dir}` does not exist" unless Dir.exist?(dir)

  resources = []
  Dir.chdir(dir) do
    Dir['**/*'].each do |path|
      content = File.read(path)
      resources << Resource.new(path, content)
    end
  end
  new(resources)
end

Instance Method Details

#each(&block) ⇒ Object



26
27
28
# File 'lib/makimono/resource_list.rb', line 26

def each(&block)
  @resources.each(&block)
end

#not_orderedObject



34
35
36
# File 'lib/makimono/resource_list.rb', line 34

def not_ordered
  @resources.reject(&:ordered?)
end

#orderedObject



30
31
32
# File 'lib/makimono/resource_list.rb', line 30

def ordered
  @resources.select(&:ordered?).sort_by(&:number)
end