File: image_methods.rb

package info (click to toggle)
ruby-compass 0.12.2~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,308 kB
  • sloc: ruby: 10,474; makefile: 42; xml: 14
file content (32 lines) | stat: -rw-r--r-- 916 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module Compass
  module SassExtensions
    module Sprites
      module ImageMethods
        # Fetches the Sprite::Image object for the supplied name
         def image_for(name)
           @images.detect { |img| img.name == name}
         end

         # Returns true if the image name has a hover selector image
         def has_hover?(name)
           !image_for("#{name}_hover").nil?
         end

         # Returns true if the image name has a target selector image
         def has_target?(name)
           !image_for("#{name}_target").nil?
         end

         # Returns true if the image name has an active selector image
         def has_active?(name)
           !image_for("#{name}_active").nil?
         end

         # Return and array of image names that make up this sprite
         def sprite_names
           image_names.map { |f| File.basename(f, '.png') }
         end
      end
    end
  end
end