Class: GallerizeCli::Image
- Inherits:
-
Object
- Object
- GallerizeCli::Image
- Includes:
- FileUtils::Verbose
- Defined in:
- lib/gallerize_cli/image.rb,
lib/gallerize_cli/image/version.rb
Defined Under Namespace
Classes: Version
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#versions ⇒ Object
readonly
Returns the value of attribute versions.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #config ⇒ Object
- #file_name ⇒ Object
-
#initialize(directory, file_path) ⇒ Image
constructor
A new instance of Image.
- #name ⇒ Object
- #original_url ⇒ Object
- #process ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(directory, file_path) ⇒ Image
Returns a new instance of Image.
29 30 31 32 33 34 |
# File 'lib/gallerize_cli/image.rb', line 29 def initialize(directory, file_path) @success = true @directory = directory @file_path = file_path generate_version_methods end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
7 8 9 |
# File 'lib/gallerize_cli/image.rb', line 7 def directory @directory end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
7 8 9 |
# File 'lib/gallerize_cli/image.rb', line 7 def file_path @file_path end |
#versions ⇒ Object (readonly)
Returns the value of attribute versions.
7 8 9 |
# File 'lib/gallerize_cli/image.rb', line 7 def versions @versions end |
Class Method Details
.generate_version_method(name) ⇒ Object
11 12 13 14 15 |
# File 'lib/gallerize_cli/image.rb', line 11 def generate_version_method(name) unless public_method_defined?("#{name}_url") define_method("#{name}_url") { self.versions[name].url } end end |
Instance Method Details
#attributes ⇒ Object
19 20 21 |
# File 'lib/gallerize_cli/image.rb', line 19 def attributes @attributes ||= fetch_attributes end |
#config ⇒ Object
51 52 53 |
# File 'lib/gallerize_cli/image.rb', line 51 def config directory.config end |
#file_name ⇒ Object
47 48 49 |
# File 'lib/gallerize_cli/image.rb', line 47 def file_name @file_name ||= File.basename(file_path) end |
#name ⇒ Object
40 41 42 43 44 45 |
# File 'lib/gallerize_cli/image.rb', line 40 def name return @name if defined?(@name) parts = file_name.split('.') parts.pop @name = parts.join('.') end |
#original_url ⇒ Object
23 24 25 26 27 |
# File 'lib/gallerize_cli/image.rb', line 23 def original_url destination = File.join(directory.images_path, file_name) cp(file_path, destination) unless File.exists?(destination) destination.gsub(directory.output_path, config.site_url) end |
#process ⇒ Object
36 37 38 |
# File 'lib/gallerize_cli/image.rb', line 36 def process versions.each { |name, version| version.process } end |
#valid? ⇒ Boolean
62 63 64 |
# File 'lib/gallerize_cli/image.rb', line 62 def valid? versions.collect(&:valid?).include?(false) end |