Class: SampleFile::Image
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #file_path ⇒ Object
-
#initialize(type = 'png', opts = {}) ⇒ Image
constructor
A new instance of Image.
-
#tmpdir ⇒ Object
Temporary directory where images will be stored.
Methods inherited from Base
Constructor Details
#initialize(type = 'png', opts = {}) ⇒ Image
Returns a new instance of Image.
7 8 9 10 11 |
# File 'lib/sample_file/image.rb', line 7 def initialize(type='png', opts={}) @type = type @width = opts[:width] || opts[:height] @height = opts[:height] || opts[:width] end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
5 6 7 |
# File 'lib/sample_file/image.rb', line 5 def height @height end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/sample_file/image.rb', line 5 def type @type end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/sample_file/image.rb', line 5 def width @width end |
Instance Method Details
#file_path ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/sample_file/image.rb', line 13 def file_path if width && height path_to_resized_image else path_to_base_image end end |
#tmpdir ⇒ Object
Temporary directory where images will be stored
23 24 25 |
# File 'lib/sample_file/image.rb', line 23 def tmpdir @tmpdir ||= File.join(Dir.tmpdir, 'sample_file', 'image') end |