Module: Compass::Core::SassExtensions::Functions::Constants

### Home Classes Methods

### In Files

- lib/compass/core/sass_extensions/functions/constants.rb

### Methods

- #is_position
- #is_position_list
- #is_url
- #opposite_position

### Class/Module Index

Quicksearch

- Compass
- Compass::BrowserSupport
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Watch
- Compass::Core
- Compass::Core::CanIUse
- Compass::Core::SassExtensions
- Compass::Core::SassExtensions::Functions
- Compass::Core::SassExtensions::Functions::Colors
- Compass::Core::SassExtensions::Functions::Configuration
- Compass::Core::SassExtensions::Functions::Constants
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::Core::SassExtensions::Functions::Display
- Compass::Core::SassExtensions::Functions::Enumerate
- Compass::Core::SassExtensions::Functions::Env
- Compass::Core::SassExtensions::Functions::Files
- Compass::Core::SassExtensions::Functions::FontFiles
- Compass::Core::SassExtensions::Functions::GradientSupport
- Compass::Core::SassExtensions::Functions::GradientSupport::Assertions
- Compass::Core::SassExtensions::Functions::GradientSupport::CSS3AngleToSVGConverter
- Compass::Core::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::Core::SassExtensions::Functions::GradientSupport::Functions
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::Core::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::Core::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::Core::SassExtensions::Functions::ImageSize
- Compass::Core::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::Core::SassExtensions::Functions::ImageSize::JPEG
- Compass::Core::SassExtensions::Functions::InlineImage
- Compass::Core::SassExtensions::Functions::Lists
- Compass::Core::SassExtensions::Functions::Math
- Compass::Core::SassExtensions::Functions::SassDeclarationHelper
- Compass::Core::SassExtensions::Functions::Selectors
- Compass::Core::SassExtensions::Functions::Urls
- Compass::Core::SassExtensions::Functions::Urls::FontUrl
- Compass::Core::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::Core::SassExtensions::Functions::Urls::ImageUrl
- Compass::Core::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::Error
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::HasDeprecatedConstantsFromCore
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::Util
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Tree
- Sass::Tree::Node

No matching classes.

# Compass::Core::SassExtensions::Functions::Constants

### Constants

POSITIONS

### Public Instance Methods

is_position(position) click to toggle source

    # File lib/compass/core/sass_extensions/functions/constants.rb, line 3
    def is_position(position)
      bool(position.is_a?(Sass::Script::Value::String) && !!(position.value =~ POSITIONS))
    end

is_position_list(position_list) click to toggle source

    # File lib/compass/core/sass_extensions/functions/constants.rb, line 6
    def is_position_list(position_list)
      bool(position_list.is_a?(Sass::Script::Value::List) && position_list.value.all?{|p| is_position(p).to_bool})
    end

is_url(string) click to toggle source

    # File lib/compass/core/sass_extensions/functions/constants.rb, line 48
    def is_url(string)
      if string.is_a?(Sass::Script::Value::String)
        is_url = !!(string.value =~ /^url\(.*\)$/)
        bool(is_url)
      else
        bool(false)
      end
    end

opposite_position(position) click to toggle source

returns the opposite position of a side or corner.

    # File lib/compass/core/sass_extensions/functions/constants.rb, line 10
    def opposite_position(position)
      position = unless position.is_a?(Sass::Script::Value::List)
        list(position, :space)
      else
        list(position.value.dup, position.separator)
      end
      position = list(position.value.map do |pos|
        if pos.is_a? Sass::Script::Value::String
          opposite = case pos.value
          when "top" then "bottom"
          when "bottom" then "top"
          when "left" then "right"
          when "right" then "left"
          when "center" then "center"
          else
            Compass::Util.compass_warn("Cannot determine the opposite position of: #{pos}")
            pos.value
          end
          identifier(opposite)
        elsif pos.is_a? Sass::Script::Value::Number
          if pos.numerator_units == ["%"] && pos.denominator_units == []
            number(100-pos.value, "%")
          else
            Compass::Util.compass_warn("Cannot determine the opposite position of: #{pos}")
            pos
          end
        else
          Compass::Util.compass_warn("Cannot determine the opposite position of: #{pos}")
          pos
        end
      end, position.separator)
      if position.value.size == 1
        position.value.first
      else
        position
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.