Class: Makimono::ResourceList
- Inherits:
-
Object
- Object
- Makimono::ResourceList
- Includes:
- Enumerable
- Defined in:
- lib/makimono/resource_list.rb
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(resources) ⇒ ResourceList
constructor
A new instance of ResourceList.
- #not_ordered ⇒ Object
- #ordered ⇒ Object
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
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_ordered ⇒ Object
34 35 36 |
# File 'lib/makimono/resource_list.rb', line 34 def not_ordered @resources.reject(&:ordered?) end |
#ordered ⇒ Object
30 31 32 |
# File 'lib/makimono/resource_list.rb', line 30 def ordered @resources.select(&:ordered?).sort_by(&:number) end |