### Home Classes Methods

### In Files

- lib/compass/sass_extensions/functions/lists.rb

### Methods

- #_compass_list
- #_compass_list_size
- #_compass_nth
- #_compass_slice
- #_compass_space_list
- #assert_list
- #blank
- #compact
- #first_value_of
- #reject

### Class/Module Index

Quicksearch

- Compass
- Compass::Actions
- Compass::AppIntegration
- Compass::AppIntegration::Helpers
- Compass::AppIntegration::Rails
- Compass::AppIntegration::StandAlone
- Compass::AppIntegration::StandAlone::ConfigurationDefaults
- Compass::AppIntegration::StandAlone::Installer
- Compass::BrowserSupport
- Compass::Commands
- Compass::Commands::Base
- Compass::Commands::CleanProject
- Compass::Commands::CleanProjectOptionsParser
- Compass::Commands::CompileProjectOptionsParser
- Compass::Commands::ConfigurationOptionsParser
- Compass::Commands::CreateProject
- Compass::Commands::CreateProjectOptionsParser
- Compass::Commands::Default
- Compass::Commands::DefaultOptionsParser
- Compass::Commands::ExtensionCommand
- Compass::Commands::ExtensionOptionsParser
- Compass::Commands::ExtensionsOptionParser
- Compass::Commands::GenerateGridBackground
- Compass::Commands::GridBackgroundOptionsParser
- Compass::Commands::Help
- Compass::Commands::HelpOptionsParser
- Compass::Commands::Imports
- Compass::Commands::InstallerCommand
- Compass::Commands::Interactive
- Compass::Commands::InteractiveOptionsParser
- Compass::Commands::ListFrameworks
- Compass::Commands::MemoryDebugger
- Compass::Commands::PrintVersion
- Compass::Commands::ProjectBase
- Compass::Commands::ProjectStats
- Compass::Commands::Registry
- Compass::Commands::Sprite
- Compass::Commands::SpriteOptionsParser
- Compass::Commands::StampPattern
- Compass::Commands::StampPatternOptionsParser
- Compass::Commands::StatsOptionsParser
- Compass::Commands::StructureOptionsParser
- Compass::Commands::UnpackExtension
- Compass::Commands::UpdateProject
- Compass::Commands::ValidateProject
- Compass::Commands::ValidationOptionsParser
- Compass::Commands::VersionOptionsParser
- Compass::Commands::WatchProject
- Compass::Commands::WatchProjectOptionsParser
- Compass::Commands::WriteConfiguration
- Compass::Compiler
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Comments
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::FileData
- Compass::Configuration::Helpers
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Serialization
- Compass::Error
- Compass::Exec
- Compass::Exec::CommandOptionParser
- Compass::Exec::GlobalOptionsParser
- Compass::Exec::Helpers
- Compass::Exec::ProjectOptionsParser
- Compass::Exec::SubCommandUI
- Compass::Exec::SwitchUI
- Compass::FilesystemConflict
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::GridBuilder
- Compass::Installers
- Compass::Installers::BareInstaller
- Compass::Installers::Base
- Compass::Installers::Manifest
- Compass::Installers::Manifest::Entry
- Compass::Installers::ManifestInstaller
- Compass::Installers::TemplateContext
- Compass::Logger
- Compass::MissingDependency
- Compass::NullLogger
- Compass::PNG
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::SassExtensions::Functions::Colors
- Compass::SassExtensions::Functions::Constants
- Compass::SassExtensions::Functions::CrossBrowserSupport
- Compass::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::SassExtensions::Functions::Display
- Compass::SassExtensions::Functions::Enumerate
- Compass::SassExtensions::Functions::Env
- Compass::SassExtensions::Functions::FontFiles
- Compass::SassExtensions::Functions::GradientSupport
- Compass::SassExtensions::Functions::GradientSupport::Assertions
- Compass::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::SassExtensions::Functions::GradientSupport::Functions
- Compass::SassExtensions::Functions::GradientSupport::Gradient
- Compass::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::SassExtensions::Functions::ImageSize
- Compass::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::SassExtensions::Functions::ImageSize::JPEG
- Compass::SassExtensions::Functions::InlineImage
- Compass::SassExtensions::Functions::Lists
- Compass::SassExtensions::Functions::Math
- Compass::SassExtensions::Functions::Selectors
- Compass::SassExtensions::Functions::Sprites
- Compass::SassExtensions::Functions::Sprites::VariableReader
- Compass::SassExtensions::Functions::Urls
- Compass::SassExtensions::Functions::Urls::FontUrl
- Compass::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::SassExtensions::Functions::Urls::ImageUrl
- Compass::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::SassExtensions::Sprites
- Compass::SassExtensions::Sprites::ChunkyPngEngine
- Compass::SassExtensions::Sprites::Engine
- Compass::SassExtensions::Sprites::Image
- Compass::SassExtensions::Sprites::ImageMethods
- Compass::SassExtensions::Sprites::ImageRow
- Compass::SassExtensions::Sprites::LayoutMethods
- Compass::SassExtensions::Sprites::RowFitter
- Compass::SassExtensions::Sprites::SpriteMap
- Compass::SassExtensions::Sprites::SpriteMethods
- Compass::SpriteException
- Compass::SpriteImporter
- Compass::Sprites
- Compass::Sprites::Binding
- Compass::Stats
- Compass::Stats::CssFile
- Compass::Stats::SassFile
- Compass::Stats::StatsVisitor
- Compass::TestCase
- Compass::Util
- Compass::Version
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Tree
- Sass::Tree::Node
- QuickCache

No matching classes.

# Compass::SassExtensions::Functions::Lists

### Public Instance Methods

_compass_list(arg) click to toggle source

Returns a list object from a value that was passed. This can be used to unpack a space separated list that got turned into a string by sass before it was passed to a mixin.

    # File lib/compass/sass_extensions/functions/lists.rb, line 43
    def _compass_list(arg)
      if arg.is_a?(Sass::Script::List)
        Sass::Script::List.new(arg.value.dup, arg.separator)
      else
        Sass::Script::List.new([arg], :space)
      end
    end

_compass_list_size(list) click to toggle source

Returns the size of the list.

    # File lib/compass/sass_extensions/functions/lists.rb, line 62
    def _compass_list_size(list)
      assert_list list
      Sass::Script::Number.new(list.value.size)
    end

_compass_nth(list, place) click to toggle source

Get the nth value from a list

    # File lib/compass/sass_extensions/functions/lists.rb, line 29
    def _compass_nth(list, place)
      assert_type list, :List
      if place.value == "first"
        list.value.first
      elsif place.value == "last"
        list.value.last
      else
        list.value[place.value - 1]
      end
    end

_compass_slice(list, start_index, end_index = nil) click to toggle source

slice a sublist from a list

    # File lib/compass/sass_extensions/functions/lists.rb, line 68
    def _compass_slice(list, start_index, end_index = nil)
      end_index ||= Sass::Script::Number.new(-1)
      start_index = start_index.value
      end_index = end_index.value
      start_index -= 1 unless start_index < 0
      end_index -= 1 unless end_index < 0
      Sass::Script::List.new list.values[start_index..end_index], list.separator
    end

_compass_space_list(list) click to toggle source

If the argument is a list, it will return a new list that is space delimited Otherwise it returns a new, single element, space-delimited list.

    # File lib/compass/sass_extensions/functions/lists.rb, line 53
    def _compass_space_list(list)
      if list.is_a?(Sass::Script::List)
        Sass::Script::List.new(list.value.dup, :space)
      else
        Sass::Script::List.new([list], :space)
      end
    end

blank(obj) click to toggle source

Returns true when the object is false, an empty string, or an empty list

    # File lib/compass/sass_extensions/functions/lists.rb, line 4
    def blank(obj)
      case obj
      when Sass::Script::Bool
        Sass::Script::Bool.new !obj.to_bool
      when Sass::Script::String
        Sass::Script::Bool.new obj.value.strip.size == 0
      when Sass::Script::List
        Sass::Script::Bool.new obj.value.size == 0 || obj.value.all?{|el| blank(el).to_bool}
      else
        Sass::Script::Bool.new false
      end
    end

compact(*args) click to toggle source

Returns a new list after removing any non-true values

    # File lib/compass/sass_extensions/functions/lists.rb, line 18
    def compact(*args)
      sep = :comma
      if args.size == 1 && args.first.is_a?(Sass::Script::List)
        list = args.first
        args = list.value
        sep = list.separator
      end
      Sass::Script::List.new(args.reject{|a| !a.to_bool}, sep)
    end

first_value_of(list) click to toggle source

returns the first value of a space delimited list.

    # File lib/compass/sass_extensions/functions/lists.rb, line 83
    def first_value_of(list)
      if list.is_a?(Sass::Script::String)
        Sass::Script::String.new(list.value.split(/\s+/).first)
      elsif defined?(Sass::Script::List) && list.is_a?(Sass::Script::List)
        list.value.first
      else
        list
      end
    end

reject(list, *values) click to toggle source

removes the given values from the list.

    # File lib/compass/sass_extensions/functions/lists.rb, line 78
    def reject(list, *values)
      Sass::Script::List.new(list.value.reject{|v| values.any?{|o| v == o}}, list.separator)
    end

### Protected Instance Methods

assert_list(value) click to toggle source

    # File lib/compass/sass_extensions/functions/lists.rb, line 95
    def assert_list(value)
      unless value.is_a?(Sass::Script::List)
        raise ArgumentError.new("#{value.inspect} is not a list")
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.