Class: Thumbnailer::Base
- Inherits:
-
Object
- Object
- Thumbnailer::Base
- Defined in:
- lib/thumbnailer/base.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#image_height ⇒ Object
readonly
Returns the value of attribute image_height.
-
#image_width ⇒ Object
readonly
Returns the value of attribute image_width.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#sequence ⇒ Object
readonly
Returns the value of attribute sequence.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #output ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/thumbnailer/base.rb', line 11 def initialize( = {}) @options = @object = [:object] @ratio = [:ratio] || 2 @width = [:width] @height = [:height] @image_width = nil @image_height = nil @prefix = [:prefix] || 'thumb_' @dir = [:dir] @sequence = nil extract_image_size end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
9 10 11 |
# File 'lib/thumbnailer/base.rb', line 9 def dir @dir end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
9 10 11 |
# File 'lib/thumbnailer/base.rb', line 9 def height @height end |
#image_height ⇒ Object (readonly)
Returns the value of attribute image_height.
9 10 11 |
# File 'lib/thumbnailer/base.rb', line 9 def image_height @image_height end |
#image_width ⇒ Object (readonly)
Returns the value of attribute image_width.
9 10 11 |
# File 'lib/thumbnailer/base.rb', line 9 def image_width @image_width end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
9 10 11 |
# File 'lib/thumbnailer/base.rb', line 9 def prefix @prefix end |
#sequence ⇒ Object (readonly)
Returns the value of attribute sequence.
9 10 11 |
# File 'lib/thumbnailer/base.rb', line 9 def sequence @sequence end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
9 10 11 |
# File 'lib/thumbnailer/base.rb', line 9 def width @width end |
Instance Method Details
#create ⇒ Object
33 34 35 |
# File 'lib/thumbnailer/base.rb', line 33 def create write end |
#output ⇒ Object
26 27 28 29 30 31 |
# File 'lib/thumbnailer/base.rb', line 26 def output path = "#{@dir}/#{@prefix}#{@file}" path = path.gsub(/\.(\w+)$/, ".#{@options[:format]}") if @options[:format].to_s.size > 0 path = insert_page(path) path end |
#write ⇒ Object
37 38 39 40 |
# File 'lib/thumbnailer/base.rb', line 37 def write resize @object.write(output) end |