Guest User

Untitled

a guest
Dec 23rd, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.93 KB | None | 0 0
  1. module Compass
  2.   module SassExtensions
  3.     module Sprites
  4.       module ImageMethods
  5.         # Fetches the Sprite::Image object for the supplied name
  6.          def image_for(name)
  7.            @images.detect { |img| img.name == name}
  8.          end
  9.  
  10.          # Returns true if the image name has a hover selector image
  11.          def has_hover?(name)
  12.            !image_for("#{name}_hover").nil?
  13.          end
  14.  
  15.          # Returns true if the image name has a target selector image
  16.          def has_target?(name)
  17.            !image_for("#{name}_target").nil?
  18.          end
  19.  
  20.          # Returns true if the image name has an active selector image
  21.          def has_active?(name)
  22.            !image_for("#{name}_active").nil?
  23.          end
  24.  
  25.          # Return and array of image names that make up this sprite
  26.          def sprite_names
  27.            image_names.map { |f| File.basename(f, '.png') }
  28.          end
  29.       end
  30.     end
  31.   end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment