Class: ImageSet
- Inherits:
-
Zarchitect
- Object
- Zarchitect
- ImageSet
- Defined in:
- lib/zarchitect/image_set.rb
Constant Summary
Constants inherited from Zarchitect
Zarchitect::ASSETDIR, Zarchitect::ASSETSDIR, Zarchitect::BUILDIR, Zarchitect::CONFIGDIR, Zarchitect::DEBUGSDIR, Zarchitect::DRAFTDIR, Zarchitect::FILEDIR, Zarchitect::FILESDIR, Zarchitect::HTMLDIR, Zarchitect::LAYOUTDIR, Zarchitect::NODEDIR, Zarchitect::SHARESDIR, Zarchitect::VERSION
Instance Attribute Summary collapse
-
#orig ⇒ Object
readonly
Returns the value of attribute orig.
-
#thumbl ⇒ Object
readonly
Returns the value of attribute thumbl.
-
#thumbs ⇒ Object
readonly
Returns the value of attribute thumbs.
Instance Method Summary collapse
-
#initialize(path, fullpath, realpath) ⇒ ImageSet
constructor
TODO abort on invalid filesize.
Methods inherited from Zarchitect
Constructor Details
#initialize(path, fullpath, realpath) ⇒ ImageSet
TODO abort on invalid filesize
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/zarchitect/image_set.rb', line 5 def initialize(path, fullpath, realpath) @thumbl = nil @thumbs = nil # path = /section/title/img.png # fullpath = _files/section/title/img.png # realpath = _html/files/section/title/img.png filename = File.basename(path, ".*") extension = File.extname(path) realdir = File.dirname(realpath) @orig = Image.new(fullpath, false) # check if thumbnails exist # attempt to create them if not thumbs_path = "#{File.join(realdir, filename)}-thumbs#{extension}" thumbl_path = "#{File.join(realdir, filename)}-thumbl#{extension}" @orig.thumbs_f = File.exist?(thumbs_path) @orig.thumbl_f = File.exist?(thumbl_path) unless @orig.thumb_small? if @orig.larger_than_thumb_small? r = @orig.create_thumbnail(thumbs_path, Zarchitect.conf.thumbs[0].to_i, Zarchitect.conf.thumbs[1].to_i) @orig.thumbs_f = r end end unless @orig.thumb_large? if @orig.larger_than_thumb_small? r = @orig.create_thumbnail(thumbl_path, Zarchitect.conf.thumbl[0].to_i, Zarchitect.conf.thumbl[1].to_i) @orig.thumbl_f = r end end # set thumbnails if created if @orig.thumb_small? @thumbs = Image.new(thumbs_path, true) end if @orig.thumb_large? @thumbl = Image.new(thumbl_path, true) end end |
Instance Attribute Details
#orig ⇒ Object (readonly)
Returns the value of attribute orig.
2 3 4 |
# File 'lib/zarchitect/image_set.rb', line 2 def orig @orig end |
#thumbl ⇒ Object (readonly)
Returns the value of attribute thumbl.
2 3 4 |
# File 'lib/zarchitect/image_set.rb', line 2 def thumbl @thumbl end |
#thumbs ⇒ Object (readonly)
Returns the value of attribute thumbs.
2 3 4 |
# File 'lib/zarchitect/image_set.rb', line 2 def thumbs @thumbs end |