Class: Hyperimage::Image
- Inherits:
-
Object
- Object
- Hyperimage::Image
- Defined in:
- app/models/hyperimage/image.rb
Class Method Summary collapse
- .all(name, format = nil, frame = nil) ⇒ Object
- .exist?(name, format = nil, frame = nil) ⇒ Boolean (also: exists?)
- .first(name, format = nil, frame = nil) ⇒ Object
- .root ⇒ Object
Class Method Details
.all(name, format = nil, frame = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/hyperimage/image.rb', line 20 def all(name, format=nil, frame=nil) # Fetch all files matching the name images = self.files(name) if format # Filter out files that don't match the format images = images.select do |file| File.fnmatch("*.#{format}", file) end if frame # Filter out files that don't match the frame images = images.select do |file| File.fnmatch("#{self.root}/#{name}/#{frame}.#{format}", file) end end end return images end |
.exist?(name, format = nil, frame = nil) ⇒ Boolean Also known as: exists?
11 12 13 |
# File 'app/models/hyperimage/image.rb', line 11 def exist?(name, format=nil, frame=nil) !!self.first(name, format, frame) end |
.first(name, format = nil, frame = nil) ⇒ Object
16 17 18 |
# File 'app/models/hyperimage/image.rb', line 16 def first(name, format=nil, frame=nil) self.all(name, format, frame).first end |
.root ⇒ Object
7 8 9 |
# File 'app/models/hyperimage/image.rb', line 7 def root @@root ||= Rails.root.join('app', 'assets', 'images') end |