Class: Caboose::BlockCacheImage
- Inherits:
-
Object
- Object
- Caboose::BlockCacheImage
- Defined in:
- app/models/caboose/block_cache_image.rb
Instance Method Summary collapse
-
#initialize(image) ⇒ BlockCacheImage
constructor
A new instance of BlockCacheImage.
- #marshal_dump ⇒ Object
- #marshal_load(arr) ⇒ Object
- #url(style = nil) ⇒ Object
Constructor Details
#initialize(image) ⇒ BlockCacheImage
Returns a new instance of BlockCacheImage.
5 6 7 8 9 10 11 12 13 14 |
# File 'app/models/caboose/block_cache_image.rb', line 5 def initialize(image) @urls = {} image.styles.each do |style| @urls[style[0].to_s] = image.url(style[0]) end #puts "--------------------------------------------" #puts "Caboose::BlockCacheImage.initialize" #puts "urls = #{@urls.inspect}" #puts "--------------------------------------------" end |
Instance Method Details
#marshal_dump ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/caboose/block_cache_image.rb', line 26 def marshal_dump arr = [] if @urls && @urls.count > 0 @urls.each do |k,v| arr << k arr << v end end return arr end |
#marshal_load(arr) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/caboose/block_cache_image.rb', line 37 def marshal_load arr @urls = {} i = 0 count = arr.count while i<count k = arr[i] @urls[k] = arr[i+1] i = i + 2 end #puts "--------------------------------------------" #puts "Caboose::BlockCacheImage.marshal_load" #puts "urls = #{@urls.inspect}" #puts "--------------------------------------------" end |
#url(style = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/models/caboose/block_cache_image.rb', line 16 def url(style = nil) #puts "--------------------------------------------" #puts "Caboose::BlockCacheImage.url" #puts "urls = #{@urls.inspect}" #puts "--------------------------------------------" return @urls['thumb'] if style.nil? return @urls[style.to_s] end |