Class: LooksGood::Image
- Inherits:
-
Object
- Object
- LooksGood::Image
- Defined in:
- lib/looks_good/image.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#image ⇒ Object
Returns the value of attribute image.
-
#path(type = :reference) ⇒ Object
Returns the value of attribute path.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(image, file_name) ⇒ Image
constructor
A new instance of Image.
- #save(type = :reference) ⇒ Object
Constructor Details
#initialize(image, file_name) ⇒ Image
Returns a new instance of Image.
8 9 10 11 |
# File 'lib/looks_good/image.rb', line 8 def initialize image, file_name @file_name = file_name @image = image end |
Instance Attribute Details
#file_name ⇒ Object
Returns the value of attribute file_name.
4 5 6 |
# File 'lib/looks_good/image.rb', line 4 def file_name @file_name end |
#image ⇒ Object
Returns the value of attribute image.
4 5 6 |
# File 'lib/looks_good/image.rb', line 4 def image @image end |
#path(type = :reference) ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/looks_good/image.rb', line 4 def path @path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/looks_good/image.rb', line 6 def type @type end |
Instance Method Details
#exists? ⇒ Boolean
20 21 22 |
# File 'lib/looks_good/image.rb', line 20 def exists? File.exists?(path) end |
#save(type = :reference) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/looks_good/image.rb', line 13 def save(type = :reference) save_path = path(type) FileUtils::mkdir_p(File.dirname(save_path)) unless File.exists?(save_path) @image.write save_path save_path end |