Class: Utopia::Tags::Gallery::ImagePath
- Inherits:
-
Object
- Object
- Utopia::Tags::Gallery::ImagePath
show all
- Defined in:
- lib/utopia/tags/gallery.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(original_path) ⇒ ImagePath
Returns a new instance of ImagePath.
43
44
45
46
|
# File 'lib/utopia/tags/gallery.rb', line 43
def initialize(original_path)
@original_path = original_path
@cache_root = @original_path.dirname + CACHE_DIR
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
79
80
81
|
# File 'lib/utopia/tags/gallery.rb', line 79
def method_missing(name, *args)
return processed(name.to_s)
end
|
Instance Attribute Details
#cache_root ⇒ Object
Returns the value of attribute cache_root.
48
49
50
|
# File 'lib/utopia/tags/gallery.rb', line 48
def cache_root
@cache_root
end
|
Class Method Details
.append_suffix(name, suffix) ⇒ Object
def basename @original_path.basename end
58
59
60
|
# File 'lib/utopia/tags/gallery.rb', line 58
def self.append_suffix(name, suffix)
name.split(".").insert(-2, suffix).join(".")
end
|
Instance Method Details
#original ⇒ Object
50
51
52
|
# File 'lib/utopia/tags/gallery.rb', line 50
def original
@original_path
end
|
#processed(process = nil) ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/utopia/tags/gallery.rb', line 62
def processed(process = nil)
if process
name = @original_path.basename
return cache_root + ImagePath.append_suffix(name, process.to_s)
else
return @original_path
end
end
|
#to_html(process = nil) ⇒ Object
71
72
73
|
# File 'lib/utopia/tags/gallery.rb', line 71
def to_html(process = nil)
Tag.new("img", {"src" => path(process)}).to_html
end
|
#to_s ⇒ Object
75
76
77
|
# File 'lib/utopia/tags/gallery.rb', line 75
def to_s
@original_path.to_s
end
|