compass/src/test/testData/gems/compass-0.13.alpha.2/lib/compass/sass_extensions/functions/gradient_support.rb
# given a position list, return a corresponding position in percents
# otherwise, returns the original argument
given a position list, return a corresponding position in percents
otherwise, returns the original argument
given a position list return a corresponding position in percents otherwise returns the original argument
def grad_point(position)
      original_value = position
      position = unless position.is_a?(Sass::Script::List)
        Sass::Script::List.new([position], :space)
      else
        Sass::Script::List.new(position.value.dup, position.separator)
      end
      unless position.value.all?{|p| is_position(p).to_bool }
        return original_value
      end
      if (position.value.first.value =~ /top|bottom/) or (position.value.last.value =~ /left|right/)
        position.value.reverse!
      end
      if position.value.size == 1
        if position.value.first.value =~ /top|bottom/
          position.value.unshift Sass::Script::String.new("center")
        elsif position.value.first.value =~ /left|right/
          position.value.push Sass::Script::String.new("center")
        end
      end
      position.value.map! do |p|
        case p.value
        when /top|left/
          Sass::Script::Number.new(0, ["%"])
        when /bottom|right/
          Sass::Script::Number.new(100, ["%"])
        when /center/
          Sass::Script::Number.new(50, ["%"])
        else
          p
        end
      end
      position
    end
def grad_point ( position ) original_value = position position = unless position . is_a? ( Sass :: Script :: List ) Sass :: Script :: List . new ( [ position ] , :space ) else Sass :: Script :: List . new ( position . value . dup , position . separator ) end unless position . value . all? { | p | is_position ( p ) . to_bool } return original_value end if ( position . value . first . value =~ / top|bottom / ) or ( position . value . last . value =~ / left|right / ) position . value . reverse! end if position . value . size == 1 if position . value . first . value =~ / top|bottom / position . value . unshift Sass :: Script :: String . new ( "center" ) elsif position . value . first . value =~ / left|right / position . value . push Sass :: Script :: String . new ( "center" ) end end position . value . map! do | p | case p . value when / top|left / Sass :: Script :: Number . new ( 0 , [ "%" ] ) when / bottom|right / Sass :: Script :: Number . new ( 100 , [ "%" ] ) when / center / Sass :: Script :: Number . new ( 50 , [ "%" ] ) else p end end position end
given a position list, return a corresponding position in percents
otherwise, returns the original argument
given a position list return a corresponding position in percents otherwise returns the original argument
# Handle unknown arguments by passing them along untouched. # browsers are pretty forgiving of reversed positions so we are too.
position