sass 3.2.19 → 3.3.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/CONTRIBUTING +1 -1
  2. data/MIT-LICENSE +2 -2
  3. data/README.md +13 -14
  4. data/REVISION +1 -1
  5. data/Rakefile +4 -6
  6. data/VERSION +1 -1
  7. data/VERSION_DATE +1 -1
  8. data/VERSION_NAME +1 -1
  9. data/bin/sass +1 -6
  10. data/bin/sass-convert +1 -6
  11. data/bin/scss +1 -6
  12. data/lib/sass/cache_stores/base.rb +0 -2
  13. data/lib/sass/cache_stores/chain.rb +1 -1
  14. data/lib/sass/cache_stores/filesystem.rb +3 -6
  15. data/lib/sass/callbacks.rb +1 -1
  16. data/lib/sass/css.rb +1 -1
  17. data/lib/sass/engine.rb +4 -11
  18. data/lib/sass/error.rb +2 -2
  19. data/lib/sass/exec.rb +10 -40
  20. data/lib/sass/importers/filesystem.rb +15 -52
  21. data/lib/sass/logger/log_level.rb +3 -3
  22. data/lib/sass/media.rb +4 -1
  23. data/lib/sass/plugin.rb +1 -2
  24. data/lib/sass/plugin/compiler.rb +18 -40
  25. data/lib/sass/plugin/staleness_checker.rb +5 -21
  26. data/lib/sass/railtie.rb +0 -1
  27. data/lib/sass/script/funcall.rb +8 -62
  28. data/lib/sass/script/functions.rb +457 -557
  29. data/lib/sass/script/lexer.rb +30 -25
  30. data/lib/sass/script/list.rb +1 -2
  31. data/lib/sass/script/literal.rb +18 -0
  32. data/lib/sass/script/null.rb +1 -4
  33. data/lib/sass/script/operation.rb +1 -0
  34. data/lib/sass/script/parser.rb +35 -42
  35. data/lib/sass/script/string.rb +1 -1
  36. data/lib/sass/script/unary_operation.rb +3 -8
  37. data/lib/sass/scss/parser.rb +14 -33
  38. data/lib/sass/scss/rx.rb +10 -3
  39. data/lib/sass/selector.rb +16 -19
  40. data/lib/sass/selector/sequence.rb +7 -16
  41. data/lib/sass/selector/simple.rb +1 -1
  42. data/lib/sass/selector/simple_sequence.rb +15 -25
  43. data/lib/sass/tree/comment_node.rb +2 -2
  44. data/lib/sass/tree/import_node.rb +2 -9
  45. data/lib/sass/tree/visitors/check_nesting.rb +2 -3
  46. data/lib/sass/tree/visitors/convert.rb +4 -9
  47. data/lib/sass/tree/visitors/cssize.rb +15 -36
  48. data/lib/sass/tree/visitors/perform.rb +20 -23
  49. data/lib/sass/tree/visitors/set_options.rb +0 -8
  50. data/lib/sass/tree/visitors/to_css.rb +1 -0
  51. data/lib/sass/util.rb +2 -120
  52. data/lib/sass/util/multibyte_string_scanner.rb +8 -29
  53. data/test/sass/conversion_test.rb +8 -33
  54. data/test/sass/css2sass_test.rb +0 -19
  55. data/test/sass/engine_test.rb +17 -129
  56. data/test/sass/extend_test.rb +24 -169
  57. data/test/sass/functions_test.rb +73 -93
  58. data/test/sass/plugin_test.rb +11 -72
  59. data/test/sass/script_conversion_test.rb +0 -14
  60. data/test/sass/script_test.rb +1 -40
  61. data/test/sass/scss/css_test.rb +3 -44
  62. data/test/sass/scss/scss_test.rb +3 -134
  63. data/test/sass/util_test.rb +0 -93
  64. data/vendor/listen/CHANGELOG.md +2 -83
  65. data/vendor/listen/Gemfile +1 -8
  66. data/vendor/listen/Guardfile +1 -1
  67. data/vendor/listen/LICENSE +1 -1
  68. data/vendor/listen/README.md +5 -8
  69. data/vendor/listen/lib/listen.rb +5 -7
  70. data/vendor/listen/lib/listen/adapter.rb +29 -76
  71. data/vendor/listen/lib/listen/adapters/darwin.rb +10 -11
  72. data/vendor/listen/lib/listen/adapters/linux.rb +30 -33
  73. data/vendor/listen/lib/listen/adapters/polling.rb +1 -2
  74. data/vendor/listen/lib/listen/adapters/windows.rb +21 -27
  75. data/vendor/listen/lib/listen/directory_record.rb +10 -63
  76. data/vendor/listen/lib/listen/listener.rb +0 -22
  77. data/vendor/listen/lib/listen/multi_listener.rb +0 -22
  78. data/vendor/listen/lib/listen/version.rb +1 -1
  79. data/vendor/listen/listen.gemspec +4 -0
  80. data/vendor/listen/spec/listen/adapter_spec.rb +4 -45
  81. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -6
  82. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -6
  83. data/vendor/listen/spec/listen/adapters/windows_spec.rb +1 -7
  84. data/vendor/listen/spec/listen/directory_record_spec.rb +4 -91
  85. data/vendor/listen/spec/listen/listener_spec.rb +0 -14
  86. data/vendor/listen/spec/listen/multi_listener_spec.rb +1 -19
  87. data/vendor/listen/spec/spec_helper.rb +3 -6
  88. data/vendor/listen/spec/support/adapter_helper.rb +212 -125
  89. data/vendor/listen/spec/support/listeners_helper.rb +1 -13
  90. data/vendor/listen/spec/support/platform_helper.rb +0 -4
  91. metadata +113 -105
  92. checksums.yaml +0 -7
  93. data/lib/sass/util/test.rb +0 -10
  94. data/test/sass/exec_test.rb +0 -86
  95. data/test/sass/results/cached_import_option.css +0 -3
  96. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  97. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  98. data/test/sass/templates/bork5.sass +0 -3
  99. data/test/sass/templates/cached_import_option.scss +0 -3
  100. data/test/sass/templates/same_name_different_ext.sass +0 -2
  101. data/test/sass/templates/same_name_different_ext.scss +0 -1
  102. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  103. data/test/sass/templates/subdir/import_up1.scss +0 -1
  104. data/test/sass/templates/subdir/import_up2.scss +0 -1
  105. data/vendor/listen/CONTRIBUTING.md +0 -38
  106. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -112
  107. data/vendor/listen/lib/listen/dependency_manager.rb +0 -126
  108. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  109. data/vendor/listen/spec/listen/dependency_manager_spec.rb +0 -107
@@ -36,14 +36,14 @@ module Sass
36
36
  end
37
37
 
38
38
  def define_logger(name, options = {})
39
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
39
+ class_eval %Q{
40
40
  def #{name}(message)
41
41
  #{options.fetch(:to, :log)}(#{name.inspect}, message)
42
42
  end
43
- RUBY
43
+ }
44
44
  end
45
45
  end
46
46
 
47
47
  end
48
48
  end
49
- end
49
+ end
@@ -140,7 +140,10 @@ module Sass::Media
140
140
  type = t1
141
141
  mod = m1.empty? ? m2 : m1
142
142
  end
143
- return Query.new([mod], [type], other.expressions + expressions)
143
+ q = Query.new([], [], other.expressions + expressions)
144
+ q.type = [type]
145
+ q.modifier = [mod]
146
+ return q
144
147
  end
145
148
 
146
149
  # Returns the CSS for the media query.
@@ -123,8 +123,7 @@ module Sass
123
123
  end
124
124
  end
125
125
 
126
- # On Rails 3+ the rails plugin is loaded at the right time in railtie.rb
127
- if defined?(ActionController) && !Sass::Util.ap_geq_3?
126
+ if defined?(ActionController)
128
127
  require 'sass/plugin/rails'
129
128
  elsif defined?(Merb::Plugins)
130
129
  require 'sass/plugin/merb'
@@ -183,7 +183,6 @@ module Sass::Plugin
183
183
  # The first string in each pair is the location of the Sass/SCSS file,
184
184
  # the second is the location of the CSS file that it should be compiled to.
185
185
  def update_stylesheets(individual_files = [])
186
- individual_files = individual_files.dup
187
186
  Sass::Plugin.checked_for_updates = true
188
187
  staleness_checker = StalenessChecker.new(engine_options)
189
188
 
@@ -234,7 +233,23 @@ module Sass::Plugin
234
233
  def watch(individual_files = [])
235
234
  update_stylesheets(individual_files)
236
235
 
237
- load_listen!
236
+ begin
237
+ require 'listen'
238
+ rescue LoadError => e
239
+ dir = Sass::Util.scope("vendor/listen/lib")
240
+ if $LOAD_PATH.include?(dir)
241
+ e.message << "\n" <<
242
+ if File.exists?(scope(".git"))
243
+ 'Run "git submodule update --init" to get the recommended version.'
244
+ else
245
+ 'Run "gem install listen" to get it.'
246
+ end
247
+ raise e
248
+ else
249
+ $LOAD_PATH.unshift dir
250
+ retry
251
+ end
252
+ end
238
253
 
239
254
  template_paths = template_locations # cache the locations
240
255
  individual_files_hash = individual_files.inject({}) do |h, files|
@@ -285,7 +300,7 @@ module Sass::Plugin
285
300
 
286
301
  # The native windows listener is much slower than the polling
287
302
  # option, according to https://github.com/nex3/sass/commit/a3031856b22bc834a5417dedecb038b7be9b9e3e#commitcomment-1295118
288
- listener.force_polling(true) if @options[:poll] || Sass::Util.windows?
303
+ listener.force_polling(true) if Sass::Util.windows?
289
304
 
290
305
  begin
291
306
  listener.start
@@ -312,43 +327,6 @@ module Sass::Plugin
312
327
 
313
328
  private
314
329
 
315
- def load_listen!
316
- if defined?(gem)
317
- begin
318
- gem 'listen', '~> 0.7'
319
- require 'listen'
320
- rescue Gem::LoadError
321
- dir = Sass::Util.scope("vendor/listen/lib")
322
- $LOAD_PATH.unshift dir
323
- begin
324
- require 'listen'
325
- rescue LoadError => e
326
- e.message << "\n" <<
327
- if File.exists?(scope(".git"))
328
- 'Run "git submodule update --init" to get the recommended version.'
329
- else
330
- 'Run "gem install listen" to get it.'
331
- end
332
- raise e
333
- end
334
- end
335
- else
336
- begin
337
- require 'listen'
338
- rescue LoadError => e
339
- dir = Sass::Util.scope("vendor/listen/lib")
340
- if $LOAD_PATH.include?(dir)
341
- raise e unless File.exists?(scope(".git"))
342
- e.message << "\n" <<
343
- 'Run "git submodule update --init" to get the recommended version.'
344
- else
345
- $LOAD_PATH.unshift dir
346
- retry
347
- end
348
- end
349
- end
350
- end
351
-
352
330
  def update_stylesheet(filename, css)
353
331
  dir = File.dirname(css)
354
332
  unless File.exists?(dir)
@@ -1,5 +1,3 @@
1
- require 'thread'
2
-
3
1
  module Sass
4
2
  module Plugin
5
3
  # The class handles `.s[ca]ss` file staleness checks via their mtime timestamps.
@@ -26,13 +24,11 @@ module Sass
26
24
  # as its instance-level caches are never explicitly expired.
27
25
  class StalenessChecker
28
26
  @dependencies_cache = {}
29
- @dependency_cache_mutex = Mutex.new
30
27
 
31
28
  class << self
32
29
  # TODO: attach this to a compiler instance.
33
30
  # @private
34
31
  attr_accessor :dependencies_cache
35
- attr_reader :dependency_cache_mutex
36
32
  end
37
33
 
38
34
  # Creates a new StalenessChecker
@@ -41,6 +37,8 @@ module Sass
41
37
  # @param options [{Symbol => Object}]
42
38
  # See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
43
39
  def initialize(options)
40
+ @dependencies = self.class.dependencies_cache
41
+
44
42
  # URIs that are being actively checked for staleness. Protects against
45
43
  # import loops.
46
44
  @actively_checking = Set.new
@@ -133,7 +131,7 @@ module Sass
133
131
  begin
134
132
  mtime = importer.mtime(uri, @options)
135
133
  if mtime.nil?
136
- with_dependency_cache {|cache| cache.delete([uri, importer])}
134
+ @dependencies.delete([uri, importer])
137
135
  nil
138
136
  else
139
137
  mtime
@@ -142,14 +140,11 @@ module Sass
142
140
  end
143
141
 
144
142
  def dependencies(uri, importer)
145
- stored_mtime, dependencies =
146
- with_dependency_cache {|cache| Sass::Util.destructure(cache[[uri, importer]])}
143
+ stored_mtime, dependencies = @dependencies[[uri, importer]]
147
144
 
148
145
  if !stored_mtime || stored_mtime < mtime(uri, importer)
149
146
  dependencies = compute_dependencies(uri, importer)
150
- with_dependency_cache do |cache|
151
- cache[[uri, importer]] = [mtime(uri, importer), dependencies]
152
- end
147
+ @dependencies[[uri, importer]] = [mtime(uri, importer), dependencies]
153
148
  end
154
149
 
155
150
  dependencies
@@ -183,17 +178,6 @@ module Sass
183
178
  def tree(uri, importer)
184
179
  @parse_trees[[uri, importer]] ||= importer.find(uri, @options).to_tree
185
180
  end
186
-
187
- # Get access to the global dependency cache in a threadsafe manner.
188
- # Inside the block, no other thread can access the dependency cache.
189
- #
190
- # @yieldparam cache [Hash] The hash that is the global dependency cache
191
- # @return The value returned by the block to which this method yields
192
- def with_dependency_cache
193
- StalenessChecker.dependency_cache_mutex.synchronize do
194
- yield StalenessChecker.dependencies_cache
195
- end
196
- end
197
181
  end
198
182
  end
199
183
  end
@@ -5,6 +5,5 @@ if defined?(ActiveSupport) && Sass::Util.has?(:public_method, ActiveSupport, :on
5
5
  ActiveSupport.on_load(:before_configuration) do
6
6
  require 'sass'
7
7
  require 'sass/plugin'
8
- require 'sass/plugin/rails'
9
8
  end
10
9
  end
@@ -54,18 +54,12 @@ module Sass
54
54
 
55
55
  # @see Node#to_sass
56
56
  def to_sass(opts = {})
57
- arg_to_sass = lambda do |arg|
58
- sass = arg.to_sass(opts)
59
- sass = "(#{sass})" if arg.is_a?(Sass::Script::List) && arg.separator == :comma
60
- sass
61
- end
62
-
63
- args = @args.map(&arg_to_sass).join(', ')
57
+ args = @args.map {|a| a.to_sass(opts)}.join(', ')
64
58
  keywords = Sass::Util.hash_to_a(@keywords).
65
- map {|k, v| "$#{dasherize(k, opts)}: #{arg_to_sass[v]}"}.join(', ')
59
+ map {|k, v| "$#{dasherize(k, opts)}: #{v.to_sass(opts)}"}.join(', ')
66
60
  if self.splat
67
61
  splat = (args.empty? && keywords.empty?) ? "" : ", "
68
- splat = "#{splat}#{arg_to_sass[self.splat]}..."
62
+ splat = "#{splat}#{self.splat.inspect}..."
69
63
  end
70
64
  "#{dasherize(name, opts)}(#{args}#{', ' unless args.empty? || keywords.empty?}#{keywords}#{splat})"
71
65
  end
@@ -100,66 +94,25 @@ module Sass
100
94
  splat = @splat.perform(environment) if @splat
101
95
  if fn = environment.function(@name)
102
96
  keywords = Sass::Util.map_hash(@keywords) {|k, v| [k, v.perform(environment)]}
103
- return without_original(perform_sass_fn(fn, args, keywords, splat))
97
+ return perform_sass_fn(fn, args, keywords, splat)
104
98
  end
105
99
 
106
100
  ruby_name = @name.tr('-', '_')
107
101
  args = construct_ruby_args(ruby_name, args, splat, environment)
108
102
 
109
103
  unless Functions.callable?(ruby_name)
110
- without_original(opts(to_literal(args)))
104
+ opts(to_literal(args))
111
105
  else
112
- without_original(opts(Functions::EvaluationContext.new(environment.options).
113
- send(ruby_name, *args)))
106
+ opts(Functions::EvaluationContext.new(environment.options).send(ruby_name, *args))
114
107
  end
115
108
  rescue ArgumentError => e
116
- message = e.message
117
-
118
109
  # If this is a legitimate Ruby-raised argument error, re-raise it.
119
110
  # Otherwise, it's an error in the user's stylesheet, so wrap it.
120
- if Sass::Util.rbx?
121
- # Rubinius has a different error report string than vanilla Ruby. It
122
- # also doesn't put the actual method for which the argument error was
123
- # thrown in the backtrace, nor does it include `send`, so we look for
124
- # `_perform`.
125
- if e.message =~ /^method '([^']+)': given (\d+), expected (\d+)/
126
- error_name, given, expected = $1, $2, $3
127
- raise e if error_name != ruby_name || e.backtrace[0] !~ /:in `_perform'$/
128
- message = "wrong number of arguments (#{given} for #{expected})"
129
- end
130
- elsif Sass::Util.jruby?
131
- if Sass::Util.jruby1_6?
132
- should_maybe_raise = e.message =~ /^wrong number of arguments \((\d+) for (\d+)\)/ &&
133
- # The one case where JRuby does include the Ruby name of the function
134
- # is manually-thrown ArgumentErrors, which are indistinguishable from
135
- # legitimate ArgumentErrors. We treat both of these as
136
- # Sass::SyntaxErrors even though it can hide Ruby errors.
137
- e.backtrace[0] !~ /:in `(block in )?#{ruby_name}'$/
138
- else
139
- should_maybe_raise = e.message =~ /^wrong number of arguments calling `[^`]+` \((\d+) for (\d+)\)/
140
- given, expected = $1, $2
141
- end
142
-
143
- if should_maybe_raise
144
- # JRuby 1.7 includes __send__ before send and _perform.
145
- trace = e.backtrace.dup
146
- raise e if !Sass::Util.jruby1_6? && trace.shift !~ /:in `__send__'$/
147
-
148
- # JRuby (as of 1.7.2) doesn't put the actual method
149
- # for which the argument error was thrown in the backtrace, so we
150
- # detect whether our send threw an argument error.
151
- if !(trace[0] =~ /:in `send'$/ && trace[1] =~ /:in `_perform'$/)
152
- raise e
153
- elsif !Sass::Util.jruby1_6?
154
- # JRuby 1.7 doesn't use standard formatting for its ArgumentErrors.
155
- message = "wrong number of arguments (#{given} for #{expected})"
156
- end
157
- end
158
- elsif e.message =~ /^wrong number of arguments \(\d+ for \d+\)/ &&
111
+ if e.message =~ /^wrong number of arguments \(\d+ for \d+\)/ &&
159
112
  e.backtrace[0] !~ /:in `(block in )?#{ruby_name}'$/
160
113
  raise e
161
114
  end
162
- raise Sass::SyntaxError.new("#{message} for `#{name}'")
115
+ raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
163
116
  end
164
117
 
165
118
  # This method is factored out from `_perform` so that compass can override
@@ -171,13 +124,6 @@ module Sass
171
124
 
172
125
  private
173
126
 
174
- def without_original(value)
175
- return value unless value.is_a?(Number)
176
- value = value.dup
177
- value.original = nil
178
- return value
179
- end
180
-
181
127
  def construct_ruby_args(name, args, splat, environment)
182
128
  args += splat.to_a if splat
183
129
 
@@ -2,7 +2,7 @@ module Sass::Script
2
2
  # Methods in this module are accessible from the SassScript context.
3
3
  # For example, you can write
4
4
  #
5
- # $color: hsl(120deg, 100%, 50%)
5
+ # $color = hsl(120deg, 100%, 50%)
6
6
  #
7
7
  # and it will call {Sass::Script::Functions#hsl}.
8
8
  #
@@ -13,10 +13,13 @@ module Sass::Script
13
13
  # ## RGB Functions
14
14
  #
15
15
  # \{#rgb rgb($red, $green, $blue)}
16
- # : Creates a {Color} from red, green, and blue values.
16
+ # : Converts an `rgb(red, green, blue)` triplet into a color.
17
17
  #
18
18
  # \{#rgba rgba($red, $green, $blue, $alpha)}
19
- # : Creates a {Color} from red, green, blue, and alpha values.
19
+ # : Converts an `rgba(red, green, blue, alpha)` quadruplet into a color.
20
+ #
21
+ # \{#rgba rgba($color, $alpha)}
22
+ # : Adds an alpha layer to any color value.
20
23
  #
21
24
  # \{#red red($color)}
22
25
  # : Gets the red component of a color.
@@ -33,11 +36,10 @@ module Sass::Script
33
36
  # ## HSL Functions
34
37
  #
35
38
  # \{#hsl hsl($hue, $saturation, $lightness)}
36
- # : Creates a {Color} from hue, saturation, and lightness values.
39
+ # : Converts an `hsl(hue, saturation, lightness)` triplet into a color.
37
40
  #
38
41
  # \{#hsla hsla($hue, $saturation, $lightness, $alpha)}
39
- # : Creates a {Color} from hue, saturation, lightness, and alpha
40
- # values.
42
+ # : Converts an `hsla(hue, saturation, lightness, alpha)` quadruplet into a color.
41
43
  #
42
44
  # \{#hue hue($color)}
43
45
  # : Gets the hue component of a color.
@@ -78,7 +80,7 @@ module Sass::Script
78
80
  # : Gets the alpha component (opacity) of a color.
79
81
  #
80
82
  # \{#rgba rgba($color, $alpha)}
81
- # : Changes the alpha component for a color.
83
+ # : Add or change an alpha layer for any color value.
82
84
  #
83
85
  # \{#opacify opacify($color, $amount)} / \{#fade_in fade-in($color, $amount)}
84
86
  # : Makes a color more opaque.
@@ -88,13 +90,13 @@ module Sass::Script
88
90
  #
89
91
  # ## Other Color Functions
90
92
  #
91
- # \{#adjust_color adjust-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\])}
92
- # : Increases or decreases one or more components of a color.
93
+ # \{#adjust_color adjust-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
94
+ # : Increase or decrease any of the components of a color.
93
95
  #
94
- # \{#scale_color scale-color($color, \[$red\], \[$green\], \[$blue\], \[$saturation\], \[$lightness\], \[$alpha\])}
95
- # : Fluidly scales one or more properties of a color.
96
+ # \{#scale_color scale-color($color, \[$red\], \[$green\], \[$blue\], \[$saturation\], \[$lightness\], \[$alpha\]}
97
+ # : Fluidly scale one or more components of a color.
96
98
  #
97
- # \{#change_color change-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\])}
99
+ # \{#change_color change-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
98
100
  # : Changes one or more properties of a color.
99
101
  #
100
102
  # \{#ie_hex_str ie-hex-str($color)}
@@ -103,7 +105,7 @@ module Sass::Script
103
105
  # ## String Functions
104
106
  #
105
107
  # \{#unquote unquote($string)}
106
- # : Removes quotes from a string.
108
+ # : Removes the quotes from a string.
107
109
  #
108
110
  # \{#quote quote($string)}
109
111
  # : Adds quotes to a string.
@@ -117,19 +119,19 @@ module Sass::Script
117
119
  # : Rounds a number to the nearest whole number.
118
120
  #
119
121
  # \{#ceil ceil($value)}
120
- # : Rounds a number up to the next whole number.
122
+ # : Rounds a number up to the nearest whole number.
121
123
  #
122
124
  # \{#floor floor($value)}
123
- # : Rounds a number down to the previous whole number.
125
+ # : Rounds a number down to the nearest whole number.
124
126
  #
125
127
  # \{#abs abs($value)}
126
128
  # : Returns the absolute value of a number.
127
129
  #
128
- # \{#min min($numbers...)\}
129
- # : Finds the minimum of several numbers.
130
+ # \{#min min($x1, $x2, ...)\}
131
+ # : Finds the minimum of several values.
130
132
  #
131
- # \{#max max($numbers...)\}
132
- # : Finds the maximum of several numbers.
133
+ # \{#max max($x1, $x2, ...)\}
134
+ # : Finds the maximum of several values.
133
135
  #
134
136
  # ## List Functions {#list-functions}
135
137
  #
@@ -145,31 +147,24 @@ module Sass::Script
145
147
  # \{#append append($list1, $val, \[$separator\])}
146
148
  # : Appends a single value onto the end of a list.
147
149
  #
148
- # \{#zip zip($lists...)}
149
- # : Combines several lists into a single multidimensional list.
150
- #
151
- # \{#index index($list, $value)}
152
- # : Returns the position of a value within a list.
153
- #
154
150
  # ## Introspection Functions
155
151
  #
156
152
  # \{#type_of type-of($value)}
157
153
  # : Returns the type of a value.
158
154
  #
159
155
  # \{#unit unit($number)}
160
- # : Returns the unit(s) associated with a number.
156
+ # : Returns the units associated with a number.
161
157
  #
162
158
  # \{#unitless unitless($number)}
163
- # : Returns whether a number has units.
159
+ # : Returns whether a number has units or not.
164
160
  #
165
161
  # \{#comparable comparable($number-1, $number-2)}
166
- # : Returns whether two numbers can be added, subtracted, or compared.
162
+ # : Returns whether two numbers can be added or compared.
167
163
  #
168
164
  # ## Miscellaneous Functions
169
165
  #
170
166
  # \{#if if($condition, $if-true, $if-false)}
171
- # : Returns one of two values, depending on whether or not `$condition` is
172
- # true.
167
+ # : Returns one of two values, depending on whether or not a condition is true.
173
168
  #
174
169
  # ## Adding Custom Functions
175
170
  #
@@ -245,12 +240,6 @@ module Sass::Script
245
240
  # but none of them but the first will be used
246
241
  # unless the user uses keyword arguments.
247
242
  #
248
- # @example
249
- # declare :rgba, [:hex, :alpha]
250
- # declare :rgba, [:red, :green, :blue, :alpha]
251
- # declare :accepts_anything, [], :var_args => true, :var_kwargs => true
252
- # declare :some_func, [:foo, :bar, :baz], :var_kwargs => true
253
- #
254
243
  # @param method_name [Symbol] The name of the method
255
244
  # whose signature is being declared.
256
245
  # @param args [Array<Symbol>] The names of the arguments for the function signature.
@@ -264,6 +253,12 @@ module Sass::Script
264
253
  # to {Sass::Script::Literal}s as the last argument.
265
254
  # In addition, if this is true and `:var_args` is not,
266
255
  # Sass will ensure that the last argument passed is a hash.
256
+ #
257
+ # @example
258
+ # declare :rgba, [:hex, :alpha]
259
+ # declare :rgba, [:red, :green, :blue, :alpha]
260
+ # declare :accepts_anything, [], :var_args => true, :var_kwargs => true
261
+ # declare :some_func, [:foo, :bar, :baz], :var_kwargs => true
267
262
  def self.declare(method_name, args, options = {})
268
263
  @signatures[method_name] ||= []
269
264
  @signatures[method_name] << Signature.new(
@@ -336,11 +331,11 @@ module Sass::Script
336
331
  # assert_type value, :Number
337
332
  # @param value [Sass::Script::Literal] A SassScript value
338
333
  # @param type [Symbol] The name of the type the value is expected to be
339
- # @param name [String, Symbol, nil] The name of the argument.
334
+ # @param name [String, nil] The name of the argument.
340
335
  def assert_type(value, type, name = nil)
341
336
  return if value.is_a?(Sass::Script.const_get(type))
342
337
  err = "#{value.inspect} is not a #{type.to_s.downcase}"
343
- err = "$#{name.to_s.gsub('_', '-')}: " + err if name
338
+ err = "$#{name}: " + err if name
344
339
  raise ArgumentError.new(err)
345
340
  end
346
341
  end
@@ -364,69 +359,67 @@ module Sass::Script
364
359
 
365
360
  # Creates a {Color} object from red, green, and blue values.
366
361
  #
362
+ # @param red [Number]
363
+ # A number between 0 and 255 inclusive,
364
+ # or between 0% and 100% inclusive
365
+ # @param green [Number]
366
+ # A number between 0 and 255 inclusive,
367
+ # or between 0% and 100% inclusive
368
+ # @param blue [Number]
369
+ # A number between 0 and 255 inclusive,
370
+ # or between 0% and 100% inclusive
367
371
  # @see #rgba
368
- # @overload rgb($red, $green, $blue)
369
- # @param $red [Number] The amount of red in the color. Must be between 0 and
370
- # 255 inclusive, or between `0%` and `100%` inclusive
371
- # @param $green [Number] The amount of green in the color. Must be between 0
372
- # and 255 inclusive, or between `0%` and `100%` inclusive
373
- # @param $blue [Number] The amount of blue in the color. Must be between 0
374
- # and 255 inclusive, or between `0%` and `100%` inclusive
375
372
  # @return [Color]
376
- # @raise [ArgumentError] if any parameter is the wrong type or out of bounds
377
373
  def rgb(red, green, blue)
378
- assert_type red, :Number, :red
379
- assert_type green, :Number, :green
380
- assert_type blue, :Number, :blue
374
+ assert_type red, :Number
375
+ assert_type green, :Number
376
+ assert_type blue, :Number
381
377
 
382
- Color.new([[red, :red], [green, :green], [blue, :blue]].map do |(c, name)|
378
+ Color.new([red, green, blue].map do |c|
383
379
  v = c.value
384
380
  if c.numerator_units == ["%"] && c.denominator_units.empty?
385
- v = Sass::Util.check_range("$#{name}: Color value", 0..100, c, '%')
381
+ v = Sass::Util.check_range("Color value", 0..100, c, '%')
386
382
  v * 255 / 100.0
387
383
  else
388
- Sass::Util.check_range("$#{name}: Color value", 0..255, c)
384
+ Sass::Util.check_range("Color value", 0..255, c)
389
385
  end
390
386
  end)
391
387
  end
392
388
  declare :rgb, [:red, :green, :blue]
393
389
 
394
- # Creates a {Color} from red, green, blue, and alpha values.
395
390
  # @see #rgb
396
- #
397
- # @overload rgba($red, $green, $blue, $alpha)
398
- # @param $red [Number] The amount of red in the color. Must be between 0
399
- # and 255 inclusive
400
- # @param $green [Number] The amount of green in the color. Must be between
401
- # 0 and 255 inclusive
402
- # @param $blue [Number] The amount of blue in the color. Must be between 0
403
- # and 255 inclusive
404
- # @param $alpha [Number] The opacity of the color. Must be between 0 and 1
405
- # inclusive
391
+ # @overload rgba(red, green, blue, alpha)
392
+ # Creates a {Color} object from red, green, and blue values,
393
+ # as well as an alpha channel indicating opacity.
394
+ #
395
+ # @param red [Number]
396
+ # A number between 0 and 255 inclusive
397
+ # @param green [Number]
398
+ # A number between 0 and 255 inclusive
399
+ # @param blue [Number]
400
+ # A number between 0 and 255 inclusive
401
+ # @param alpha [Number]
402
+ # A number between 0 and 1
406
403
  # @return [Color]
407
- # @raise [ArgumentError] if any parameter is the wrong type or out of
408
- # bounds
409
404
  #
410
- # @overload rgba($color, $alpha)
411
- # Sets the opacity of an existing color.
405
+ # @overload rgba(color, alpha)
406
+ # Sets the opacity of a color.
412
407
  #
413
408
  # @example
414
409
  # rgba(#102030, 0.5) => rgba(16, 32, 48, 0.5)
415
410
  # rgba(blue, 0.2) => rgba(0, 0, 255, 0.2)
416
411
  #
417
- # @param $color [Color] The color whose opacity will be changed.
418
- # @param $alpha [Number] The new opacity of the color. Must be between 0
419
- # and 1 inclusive
412
+ # @param color [Color]
413
+ # @param alpha [Number]
414
+ # A number between 0 and 1
420
415
  # @return [Color]
421
- # @raise [ArgumentError] if `$alpha` is out of bounds or either parameter
422
- # is the wrong type
423
416
  def rgba(*args)
424
417
  case args.size
425
418
  when 2
426
419
  color, alpha = args
427
420
 
428
- assert_type color, :Color, :color
429
- assert_type alpha, :Number, :alpha
421
+ assert_type color, :Color
422
+ assert_type alpha, :Number
430
423
 
431
424
  Sass::Util.check_range('Alpha channel', 0..1, alpha)
432
425
  color.with(:alpha => alpha.value)
@@ -440,50 +433,43 @@ module Sass::Script
440
433
  declare :rgba, [:red, :green, :blue, :alpha]
441
434
  declare :rgba, [:color, :alpha]
442
435
 
443
- # Creates a {Color} from hue, saturation, and lightness values. Uses the
444
- # algorithm from the [CSS3 spec][].
445
- #
446
- # [CSS3 spec]: http://www.w3.org/TR/css3-color/#hsl-color
436
+ # Creates a {Color} object from hue, saturation, and lightness.
437
+ # Uses the algorithm from the [CSS3 spec](http://www.w3.org/TR/css3-color/#hsl-color).
447
438
  #
439
+ # @param hue [Number] The hue of the color.
440
+ # Should be between 0 and 360 degrees, inclusive
441
+ # @param saturation [Number] The saturation of the color.
442
+ # Must be between `0%` and `100%`, inclusive
443
+ # @param lightness [Number] The lightness of the color.
444
+ # Must be between `0%` and `100%`, inclusive
445
+ # @return [Color] The resulting color
448
446
  # @see #hsla
449
- # @overload hsl($hue, $saturation, $lightness)
450
- # @param $hue [Number] The hue of the color. Should be between 0 and 360
451
- # degrees, inclusive
452
- # @param $saturation [Number] The saturation of the color. Must be between
453
- # `0%` and `100%`, inclusive
454
- # @param $lightness [Number] The lightness of the color. Must be between
455
- # `0%` and `100%`, inclusive
456
- # @return [Color]
457
- # @raise [ArgumentError] if `$saturation` or `$lightness` are out of bounds
458
- # or any parameter is the wrong type
447
+ # @raise [ArgumentError] if `saturation` or `lightness` are out of bounds
459
448
  def hsl(hue, saturation, lightness)
460
449
  hsla(hue, saturation, lightness, Number.new(1))
461
450
  end
462
451
  declare :hsl, [:hue, :saturation, :lightness]
463
452
 
464
- # Creates a {Color} from hue, saturation, lightness, and alpha
465
- # values. Uses the algorithm from the [CSS3 spec][].
466
- #
467
- # [CSS3 spec]: http://www.w3.org/TR/css3-color/#hsl-color
468
- #
453
+ # Creates a {Color} object from hue, saturation, and lightness,
454
+ # as well as an alpha channel indicating opacity.
455
+ # Uses the algorithm from the [CSS3 spec](http://www.w3.org/TR/css3-color/#hsl-color).
456
+ #
457
+ # @param hue [Number] The hue of the color.
458
+ # Should be between 0 and 360 degrees, inclusive
459
+ # @param saturation [Number] The saturation of the color.
460
+ # Must be between `0%` and `100%`, inclusive
461
+ # @param lightness [Number] The lightness of the color.
462
+ # Must be between `0%` and `100%`, inclusive
463
+ # @param alpha [Number] The opacity of the color.
464
+ # Must be between 0 and 1, inclusive
465
+ # @return [Color] The resulting color
469
466
  # @see #hsl
470
- # @overload hsla($hue, $saturation, $lightness, $alpha)
471
- # @param $hue [Number] The hue of the color. Should be between 0 and 360
472
- # degrees, inclusive
473
- # @param $saturation [Number] The saturation of the color. Must be between
474
- # `0%` and `100%`, inclusive
475
- # @param $lightness [Number] The lightness of the color. Must be between
476
- # `0%` and `100%`, inclusive
477
- # @param $alpha [Number] The opacity of the color. Must be between 0 and 1,
478
- # inclusive
479
- # @return [Color]
480
- # @raise [ArgumentError] if `$saturation`, `$lightness`, or `$alpha` are out
481
- # of bounds or any parameter is the wrong type
467
+ # @raise [ArgumentError] if `saturation`, `lightness`, or `alpha` are out of bounds
482
468
  def hsla(hue, saturation, lightness, alpha)
483
- assert_type hue, :Number, :hue
484
- assert_type saturation, :Number, :saturation
485
- assert_type lightness, :Number, :lightness
486
- assert_type alpha, :Number, :alpha
469
+ assert_type hue, :Number
470
+ assert_type saturation, :Number
471
+ assert_type lightness, :Number
472
+ assert_type alpha, :Number
487
473
 
488
474
  Sass::Util.check_range('Alpha channel', 0..1, alpha)
489
475
 
@@ -495,112 +481,101 @@ module Sass::Script
495
481
  end
496
482
  declare :hsla, [:hue, :saturation, :lightness, :alpha]
497
483
 
498
- # Gets the red component of a color. Calculated from HSL where necessary via
499
- # [this algorithm][hsl-to-rgb].
500
- #
501
- # [hsl-to-rgb]: http://www.w3.org/TR/css3-color/#hsl-color
484
+ # Returns the red component of a color.
502
485
  #
503
- # @overload red($color)
504
- # @param $color [Color]
505
- # @return [Number] The red component, between 0 and 255 inclusive
506
- # @raise [ArgumentError] if `$color` isn't a color
486
+ # @param color [Color]
487
+ # @return [Number]
488
+ # @raise [ArgumentError] If `color` isn't a color
507
489
  def red(color)
508
- assert_type color, :Color, :color
490
+ assert_type color, :Color
509
491
  Sass::Script::Number.new(color.red)
510
492
  end
511
493
  declare :red, [:color]
512
494
 
513
- # Gets the green component of a color. Calculated from HSL where necessary
514
- # via [this algorithm][hsl-to-rgb].
515
- #
516
- # [hsl-to-rgb]: http://www.w3.org/TR/css3-color/#hsl-color
495
+ # Returns the green component of a color.
517
496
  #
518
- # @overload green($color)
519
- # @param $color [Color]
520
- # @return [Number] The green component, between 0 and 255 inclusive
521
- # @raise [ArgumentError] if `$color` isn't a color
497
+ # @param color [Color]
498
+ # @return [Number]
499
+ # @raise [ArgumentError] If `color` isn't a color
522
500
  def green(color)
523
- assert_type color, :Color, :color
501
+ assert_type color, :Color
524
502
  Sass::Script::Number.new(color.green)
525
503
  end
526
504
  declare :green, [:color]
527
505
 
528
- # Gets the blue component of a color. Calculated from HSL where necessary
529
- # via [this algorithm][hsl-to-rgb].
506
+ # Returns the blue component of a color.
530
507
  #
531
- # [hsl-to-rgb]: http://www.w3.org/TR/css3-color/#hsl-color
532
- #
533
- # @overload blue($color)
534
- # @param $color [Color]
535
- # @return [Number] The blue component, between 0 and 255 inclusive
536
- # @raise [ArgumentError] if `$color` isn't a color
508
+ # @param color [Color]
509
+ # @return [Number]
510
+ # @raise [ArgumentError] If `color` isn't a color
537
511
  def blue(color)
538
- assert_type color, :Color, :color
512
+ assert_type color, :Color
539
513
  Sass::Script::Number.new(color.blue)
540
514
  end
541
515
  declare :blue, [:color]
542
516
 
543
- # Returns the hue component of a color. See [the CSS3 HSL
544
- # specification][hsl]. Calculated from RGB where necessary via [this
545
- # algorithm][rgb-to-hsl].
517
+ # Returns the hue component of a color.
518
+ #
519
+ # See [the CSS3 HSL specification](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
546
520
  #
547
- # [hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
548
- # [rgb-to-hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
521
+ # Calculated from RGB where necessary via [this algorithm](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
549
522
  #
550
- # @overload hue($color)
551
- # @param $color [Color]
552
- # @return [Number] The hue component, between 0deg and 360deg
553
- # @raise [ArgumentError] if `$color` isn't a color
523
+ # @param color [Color]
524
+ # @return [Number] between 0deg and 360deg
525
+ # @see #adjust_hue
526
+ # @raise [ArgumentError] if `color` isn't a color
554
527
  def hue(color)
555
- assert_type color, :Color, :color
528
+ assert_type color, :Color
556
529
  Sass::Script::Number.new(color.hue, ["deg"])
557
530
  end
558
531
  declare :hue, [:color]
559
532
 
560
- # Returns the saturation component of a color. See [the CSS3 HSL
561
- # specification][hsl]. Calculated from RGB where necessary via [this
562
- # algorithm][rgb-to-hsl].
533
+ # Returns the saturation component of a color.
563
534
  #
564
- # [hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
565
- # [rgb-to-hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
535
+ # See [the CSS3 HSL specification](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
566
536
  #
567
- # @overload saturation($color)
568
- # @param $color [Color]
569
- # @return [Number] The saturation component, between 0% and 100%
570
- # @raise [ArgumentError] if `$color` isn't a color
537
+ # Calculated from RGB where necessary via [this algorithm](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
538
+ #
539
+ # @param color [Color]
540
+ # @return [Number] between 0% and 100%
541
+ # @see #saturate
542
+ # @see #desaturate
543
+ # @raise [ArgumentError] if `color` isn't a color
571
544
  def saturation(color)
572
- assert_type color, :Color, :color
545
+ assert_type color, :Color
573
546
  Sass::Script::Number.new(color.saturation, ["%"])
574
547
  end
575
548
  declare :saturation, [:color]
576
549
 
577
- # Returns the lightness component of a color. See [the CSS3 HSL
578
- # specification][hsl]. Calculated from RGB where necessary via [this
579
- # algorithm][rgb-to-hsl].
550
+ # Returns the hue component of a color.
580
551
  #
581
- # [hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
582
- # [rgb-to-hsl]: http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
552
+ # See [the CSS3 HSL specification](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
583
553
  #
584
- # @overload lightness($color)
585
- # @param $color [Color]
586
- # @return [Number] The lightness component, between 0% and 100%
587
- # @raise [ArgumentError] if `$color` isn't a color
554
+ # Calculated from RGB where necessary via [this algorithm](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
555
+ #
556
+ # @param color [Color]
557
+ # @return [Number] between 0% and 100%
558
+ # @see #lighten
559
+ # @see #darken
560
+ # @raise [ArgumentError] if `color` isn't a color
588
561
  def lightness(color)
589
- assert_type color, :Color, :color
562
+ assert_type color, :Color
590
563
  Sass::Script::Number.new(color.lightness, ["%"])
591
564
  end
592
565
  declare :lightness, [:color]
593
566
 
594
- # Returns the alpha component (opacity) of a color. This is 1 unless
595
- # otherwise specified.
567
+ # Returns the alpha component (opacity) of a color.
568
+ # This is 1 unless otherwise specified.
596
569
  #
597
- # This function also supports the proprietary Microsoft `alpha(opacity=20)`
598
- # syntax as a special case.
570
+ # This function also supports the proprietary Microsoft
571
+ # `alpha(opacity=20)` syntax.
599
572
  #
600
- # @overload alpha($color)
601
- # @param $color [Color]
602
- # @return [Number] The alpha component, between 0 and 1
603
- # @raise [ArgumentError] if `$color` isn't a color
573
+ # @overload def alpha(color)
574
+ # @param color [Color]
575
+ # @return [Number]
576
+ # @see #opacify
577
+ # @see #transparentize
578
+ # @raise [ArgumentError] If `color` isn't a color
604
579
  def alpha(*args)
605
580
  if args.all? do |a|
606
581
  a.is_a?(Sass::Script::String) && a.type == :identifier &&
@@ -612,39 +587,39 @@ module Sass::Script
612
587
 
613
588
  raise ArgumentError.new("wrong number of arguments (#{args.size} for 1)") if args.size != 1
614
589
 
615
- assert_type args.first, :Color, :color
590
+ assert_type args.first, :Color
616
591
  Sass::Script::Number.new(args.first.alpha)
617
592
  end
618
593
  declare :alpha, [:color]
619
594
 
620
- # Returns the alpha component (opacity) of a color. This is 1 unless
621
- # otherwise specified.
595
+ # Returns the alpha component (opacity) of a color.
596
+ # This is 1 unless otherwise specified.
622
597
  #
623
- # @overload opacity($color)
624
- # @param $color [Color]
625
- # @return [Number] The alpha component, between 0 and 1
626
- # @raise [ArgumentError] if `$color` isn't a color
598
+ # @param color [Color]
599
+ # @return [Number]
600
+ # @see #opacify
601
+ # @see #transparentize
602
+ # @raise [ArgumentError] If `color` isn't a color
627
603
  def opacity(color)
628
604
  return Sass::Script::String.new("opacity(#{color})") if color.is_a?(Sass::Script::Number)
629
- assert_type color, :Color, :color
605
+ assert_type color, :Color
630
606
  Sass::Script::Number.new(color.alpha)
631
607
  end
632
608
  declare :opacity, [:color]
633
609
 
634
- # Makes a color more opaque. Takes a color and a number between 0 and 1, and
635
- # returns a color with the opacity increased by that amount.
610
+ # Makes a color more opaque.
611
+ # Takes a color and an amount between 0 and 1,
612
+ # and returns a color with the opacity increased by that value.
636
613
  #
637
- # @see #transparentize
638
614
  # @example
639
615
  # opacify(rgba(0, 0, 0, 0.5), 0.1) => rgba(0, 0, 0, 0.6)
640
616
  # opacify(rgba(0, 0, 17, 0.8), 0.2) => #001
641
- # @overload opacify($color, $amount)
642
- # @param $color [Color]
643
- # @param $amount [Number] The amount to increase the opacity by, between 0
644
- # and 1
617
+ # @param color [Color]
618
+ # @param amount [Number]
645
619
  # @return [Color]
646
- # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
647
- # is the wrong type
620
+ # @see #transparentize
621
+ # @raise [ArgumentError] If `color` isn't a color,
622
+ # or `number` isn't a number between 0 and 1
648
623
  def opacify(color, amount)
649
624
  _adjust(color, amount, :alpha, 0..1, :+)
650
625
  end
@@ -653,20 +628,19 @@ module Sass::Script
653
628
  alias_method :fade_in, :opacify
654
629
  declare :fade_in, [:color, :amount]
655
630
 
656
- # Makes a color more transparent. Takes a color and a number between 0 and
657
- # 1, and returns a color with the opacity decreased by that amount.
631
+ # Makes a color more transparent.
632
+ # Takes a color and an amount between 0 and 1,
633
+ # and returns a color with the opacity decreased by that value.
658
634
  #
659
- # @see #opacify
660
635
  # @example
661
636
  # transparentize(rgba(0, 0, 0, 0.5), 0.1) => rgba(0, 0, 0, 0.4)
662
637
  # transparentize(rgba(0, 0, 0, 0.8), 0.2) => rgba(0, 0, 0, 0.6)
663
- # @overload transparentize($color, $amount)
664
- # @param $color [Color]
665
- # @param $amount [Number] The amount to decrease the opacity by, between 0
666
- # and 1
638
+ # @param color [Color]
639
+ # @param amount [Number]
667
640
  # @return [Color]
668
- # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
669
- # is the wrong type
641
+ # @see #opacify
642
+ # @raise [ArgumentError] If `color` isn't a color,
643
+ # or `number` isn't a number between 0 and 1
670
644
  def transparentize(color, amount)
671
645
  _adjust(color, amount, :alpha, 0..1, :-)
672
646
  end
@@ -675,58 +649,56 @@ module Sass::Script
675
649
  alias_method :fade_out, :transparentize
676
650
  declare :fade_out, [:color, :amount]
677
651
 
678
- # Makes a color lighter. Takes a color and a number between `0%` and `100%`,
679
- # and returns a color with the lightness increased by that amount.
652
+ # Makes a color lighter.
653
+ # Takes a color and an amount between 0% and 100%,
654
+ # and returns a color with the lightness increased by that value.
680
655
  #
681
- # @see #darken
682
656
  # @example
683
657
  # lighten(hsl(0, 0%, 0%), 30%) => hsl(0, 0, 30)
684
658
  # lighten(#800, 20%) => #e00
685
- # @overload lighten($color, $amount)
686
- # @param $color [Color]
687
- # @param $amount [Number] The amount to increase the lightness by, between
688
- # `0%` and `100%`
659
+ # @param color [Color]
660
+ # @param amount [Number]
689
661
  # @return [Color]
690
- # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
691
- # is the wrong type
662
+ # @see #darken
663
+ # @raise [ArgumentError] If `color` isn't a color,
664
+ # or `number` isn't a number between 0% and 100%
692
665
  def lighten(color, amount)
693
666
  _adjust(color, amount, :lightness, 0..100, :+, "%")
694
667
  end
695
668
  declare :lighten, [:color, :amount]
696
669
 
697
- # Makes a color darker. Takes a color and a number between 0% and 100%, and
698
- # returns a color with the lightness decreased by that amount.
670
+ # Makes a color darker.
671
+ # Takes a color and an amount between 0% and 100%,
672
+ # and returns a color with the lightness decreased by that value.
699
673
  #
700
- # @see #lighten
701
674
  # @example
702
675
  # darken(hsl(25, 100%, 80%), 30%) => hsl(25, 100%, 50%)
703
676
  # darken(#800, 20%) => #200
704
- # @overload darken($color, $amount)
705
- # @param $color [Color]
706
- # @param $amount [Number] The amount to dencrease the lightness by, between
707
- # `0%` and `100%`
677
+ # @param color [Color]
678
+ # @param amount [Number]
708
679
  # @return [Color]
709
- # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
710
- # is the wrong type
680
+ # @see #lighten
681
+ # @raise [ArgumentError] If `color` isn't a color,
682
+ # or `number` isn't a number between 0% and 100%
711
683
  def darken(color, amount)
712
684
  _adjust(color, amount, :lightness, 0..100, :-, "%")
713
685
  end
714
686
  declare :darken, [:color, :amount]
715
687
 
716
- # Makes a color more saturated. Takes a color and a number between 0% and
717
- # 100%, and returns a color with the saturation increased by that amount.
688
+ # Makes a color more saturated.
689
+ # Takes a color and an amount between 0% and 100%,
690
+ # and returns a color with the saturation increased by that value.
718
691
  #
719
- # @see #desaturate
720
692
  # @example
721
693
  # saturate(hsl(120, 30%, 90%), 20%) => hsl(120, 50%, 90%)
722
694
  # saturate(#855, 20%) => #9e3f3f
723
- # @overload saturate($color, $amount)
724
- # @param $color [Color]
725
- # @param $amount [Number] The amount to increase the saturation by, between
726
- # `0%` and `100%`
727
- # @return [Color]
728
- # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
729
- # is the wrong type
695
+ # @overload saturate(color, amount)
696
+ # @param color [Color]
697
+ # @param amount [Number]
698
+ # @return [Color]
699
+ # @see #desaturate
700
+ # @raise [ArgumentError] If `color` isn't a color,
701
+ # or `number` isn't a number between 0% and 100%
730
702
  def saturate(color, amount = nil)
731
703
  # Support the filter effects definition of saturate.
732
704
  # https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html
@@ -736,97 +708,93 @@ module Sass::Script
736
708
  declare :saturate, [:color, :amount]
737
709
  declare :saturate, [:amount]
738
710
 
739
- # Makes a color less saturated. Takes a color and a number between 0% and
740
- # 100%, and returns a color with the saturation decreased by that value.
711
+ # Makes a color less saturated.
712
+ # Takes a color and an amount between 0% and 100%,
713
+ # and returns a color with the saturation decreased by that value.
741
714
  #
742
- # @see #saturate
743
715
  # @example
744
716
  # desaturate(hsl(120, 30%, 90%), 20%) => hsl(120, 10%, 90%)
745
717
  # desaturate(#855, 20%) => #726b6b
746
- # @overload desaturate($color, $amount)
747
- # @param $color [Color]
748
- # @param $amount [Number] The amount to decrease the saturation by, between
749
- # `0%` and `100%`
718
+ # @param color [Color]
719
+ # @param amount [Number]
750
720
  # @return [Color]
751
- # @raise [ArgumentError] if `$amount` is out of bounds, or either parameter
752
- # is the wrong type
721
+ # @see #saturate
722
+ # @raise [ArgumentError] If `color` isn't a color,
723
+ # or `number` isn't a number between 0% and 100%
753
724
  def desaturate(color, amount)
754
725
  _adjust(color, amount, :saturation, 0..100, :-, "%")
755
726
  end
756
727
  declare :desaturate, [:color, :amount]
757
728
 
758
- # Changes the hue of a color. Takes a color and a number of degrees (usually
759
- # between `-360deg` and `360deg`), and returns a color with the hue rotated
760
- # along the color wheel by that amount.
729
+ # Changes the hue of a color while retaining the lightness and saturation.
730
+ # Takes a color and a number of degrees (usually between -360deg and 360deg),
731
+ # and returns a color with the hue rotated by that value.
761
732
  #
762
733
  # @example
763
734
  # adjust-hue(hsl(120, 30%, 90%), 60deg) => hsl(180, 30%, 90%)
764
735
  # adjust-hue(hsl(120, 30%, 90%), 060deg) => hsl(60, 30%, 90%)
765
736
  # adjust-hue(#811, 45deg) => #886a11
766
- # @overload adjust_hue($color, $degrees)
767
- # @param $color [Color]
768
- # @param $degrees [Number] The number of degrees to rotate the hue
737
+ # @param color [Color]
738
+ # @param amount [Number]
769
739
  # @return [Color]
770
- # @raise [ArgumentError] if either parameter is the wrong type
740
+ # @raise [ArgumentError] If `color` isn't a color, or `number` isn't a number
771
741
  def adjust_hue(color, degrees)
772
- assert_type color, :Color, :color
773
- assert_type degrees, :Number, :degrees
742
+ assert_type color, :Color
743
+ assert_type degrees, :Number
774
744
  color.with(:hue => color.hue + degrees.value)
775
745
  end
776
746
  declare :adjust_hue, [:color, :degrees]
777
747
 
778
- # Converts a color into the format understood by IE filters.
748
+ # Returns an IE hex string for a color with an alpha channel
749
+ # suitable for passing to IE filters.
779
750
  #
780
751
  # @example
781
752
  # ie-hex-str(#abc) => #FFAABBCC
782
753
  # ie-hex-str(#3322BB) => #FF3322BB
783
754
  # ie-hex-str(rgba(0, 255, 0, 0.5)) => #8000FF00
784
- # @overload ie_hex_str($color)
785
- # @param $color [Color]
786
- # @return [String] The IE-formatted string representation of the color
787
- # @raise [ArgumentError] if `$color` isn't a color
755
+ # @param color [Color]
756
+ # @return [String]
757
+ # @raise [ArgumentError] If `color` isn't a color
788
758
  def ie_hex_str(color)
789
- assert_type color, :Color, :color
759
+ assert_type color, :Color
790
760
  alpha = (color.alpha * 255).round.to_s(16).rjust(2, '0')
791
761
  Sass::Script::String.new("##{alpha}#{color.send(:hex_str)[1..-1]}".upcase)
792
762
  end
793
763
  declare :ie_hex_str, [:color]
794
764
 
795
- # Increases or decreases one or more properties of a color. This can change
796
- # the red, green, blue, hue, saturation, value, and alpha properties. The
797
- # properties are specified as keyword arguments, and are added to or
798
- # subtracted from the color's current value for that property.
765
+ # Adjusts one or more properties of a color.
766
+ # This can change the red, green, blue, hue, saturation, value, and alpha properties.
767
+ # The properties are specified as keyword arguments,
768
+ # and are added to or subtracted from the color's current value for that property.
769
+ #
770
+ # `$red`, `$green`, and `$blue` properties should be between 0 and 255.
771
+ # `$saturation` and `$lightness` should be between 0% and 100%.
772
+ # `$alpha` should be between 0 and 1.
799
773
  #
800
- # All properties are optional. You can't specify both RGB properties
801
- # (`$red`, `$green`, `$blue`) and HSL properties (`$hue`, `$saturation`,
802
- # `$value`) at the same time.
774
+ # All properties are optional.
775
+ # You can't specify both RGB properties (`$red`, `$green`, `$blue`)
776
+ # and HSL properties (`$hue`, `$saturation`, `$value`) at the same time.
803
777
  #
804
778
  # @example
805
779
  # adjust-color(#102030, $blue: 5) => #102035
806
780
  # adjust-color(#102030, $red: -5, $blue: 5) => #0b2035
807
781
  # adjust-color(hsl(25, 100%, 80%), $lightness: -30%, $alpha: -0.4) => hsla(25, 100%, 50%, 0.6)
808
- # @overload adjust_color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])
809
- # @param $color [Color]
810
- # @param $red [Number] The adjustment to make on the red component, between
811
- # -255 and 255 inclusive
812
- # @param $green [Number] The adjustment to make on the green component,
813
- # between -255 and 255 inclusive
814
- # @param $blue [Number] The adjustment to make on the blue component, between
815
- # -255 and 255 inclusive
816
- # @param $hue [Number] The adjustment to make on the hue component, in
817
- # degrees
818
- # @param $saturation [Number] The adjustment to make on the saturation
819
- # component, between `-100%` and `100%` inclusive
820
- # @param $lightness [Number] The adjustment to make on the lightness
821
- # component, between `-100%` and `100%` inclusive
822
- # @param $alpha [Number] The adjustment to make on the alpha component,
823
- # between -1 and 1 inclusive
782
+ # @param color [Color]
783
+ # @param red [Number]
784
+ # @param green [Number]
785
+ # @param blue [Number]
786
+ # @param hue [Number]
787
+ # @param saturation [Number]
788
+ # @param lightness [Number]
789
+ # @param alpha [Number]
824
790
  # @return [Color]
825
- # @raise [ArgumentError] if any parameter is the wrong type or out-of
826
- # bounds, or if RGB properties and HSL properties are adjusted at the
827
- # same time
791
+ # @raise [ArgumentError] if `color` is not a color,
792
+ # if any keyword argument is not a number,
793
+ # if any keyword argument is not in the legal range,
794
+ # if an unexpected keyword argument is given,
795
+ # or if both HSL and RGB properties are given.
828
796
  def adjust_color(color, kwargs)
829
- assert_type color, :Color, :color
797
+ assert_type color, :Color
830
798
  with = Sass::Util.map_hash({
831
799
  "red" => [-255..255, ""],
832
800
  "green" => [-255..255, ""],
@@ -854,47 +822,47 @@ module Sass::Script
854
822
  end
855
823
  declare :adjust_color, [:color], :var_kwargs => true
856
824
 
857
- # Fluidly scales one or more properties of a color. Unlike
858
- # \{#adjust_color adjust-color}, which changes a color's properties by fixed
859
- # amounts, \{#scale_color scale-color} fluidly changes them based on how
860
- # high or low they already are. That means that lightening an already-light
861
- # color with \{#scale_color scale-color} won't change the lightness much,
862
- # but lightening a dark color by the same amount will change it more
863
- # dramatically. This has the benefit of making `scale-color($color, ...)`
864
- # have a similar effect regardless of what `$color` is.
865
- #
866
- # For example, the lightness of a color can be anywhere between `0%` and
867
- # `100%`. If `scale-color($color, $lightness: 40%)` is called, the resulting
868
- # color's lightness will be 40% of the way between its original lightness
869
- # and 100. If `scale-color($color, $lightness: -40%)` is called instead, the
870
- # lightness will be 40% of the way between the original and 0.
871
- #
872
- # This can change the red, green, blue, saturation, value, and alpha
873
- # properties. The properties are specified as keyword arguments. All
874
- # arguments should be percentages between `0%` and `100%`.
875
- #
876
- # All properties are optional. You can't specify both RGB properties
877
- # (`$red`, `$green`, `$blue`) and HSL properties (`$saturation`, `$value`)
878
- # at the same time.
825
+ # Scales one or more properties of a color by a percentage value.
826
+ # Unlike \{#adjust_color adjust-color}, which changes a color's properties by fixed amounts,
827
+ # \{#scale_color scale-color} fluidly changes them based on how high or low they already are.
828
+ # That means that lightening an already-light color with \{#scale_color scale-color}
829
+ # won't change the lightness much,
830
+ # but lightening a dark color by the same amount will change it more dramatically.
831
+ # This has the benefit of making `scale-color($color, ...)` have a similar effect
832
+ # regardless of what `$color` is.
833
+ #
834
+ # For example, the lightness of a color can be anywhere between 0 and 100.
835
+ # If `scale-color($color, $lightness: 40%)` is called, the resulting color's lightness
836
+ # will be 40% of the way between its original lightness and 100.
837
+ # If `scale-color($color, $lightness: -40%)` is called instead,
838
+ # the lightness will be 40% of the way between the original and 0.
839
+ #
840
+ # This can change the red, green, blue, saturation, value, and alpha properties.
841
+ # The properties are specified as keyword arguments.
842
+ # All arguments should be percentages between 0% and 100%.
843
+ #
844
+ # All properties are optional.
845
+ # You can't specify both RGB properties (`$red`, `$green`, `$blue`)
846
+ # and HSL properties (`$saturation`, `$value`) at the same time.
879
847
  #
880
848
  # @example
881
- # scale-color(hsl(120, 70%, 80%), $lightness: 50%) => hsl(120, 70%, 90%)
882
- # scale-color(rgb(200, 150%, 170%), $green: -40%, $blue: 70%) => rgb(200, 90, 229)
883
- # scale-color(hsl(200, 70%, 80%), $saturation: -90%, $alpha: -30%) => hsla(200, 7%, 80%, 0.7)
884
- # @overload scale_color($color, [$red], [$green], [$blue], [$saturation], [$lightness], [$alpha])
885
- # @param $color [Color]
886
- # @param $red [Number]
887
- # @param $green [Number]
888
- # @param $blue [Number]
889
- # @param $saturation [Number]
890
- # @param $lightness [Number]
891
- # @param $alpha [Number]
849
+ # scale-color(hsl(120, 70, 80), $lightness: 50%) => hsl(120, 70, 90)
850
+ # scale-color(rgb(200, 150, 170), $green: -40%, $blue: 70%) => rgb(200, 90, 229)
851
+ # scale-color(hsl(200, 70, 80), $saturation: -90%, $alpha: -30%) => hsla(200, 7, 80, 0.7)
852
+ # @param color [Color]
853
+ # @param red [Number]
854
+ # @param green [Number]
855
+ # @param blue [Number]
856
+ # @param saturation [Number]
857
+ # @param lightness [Number]
858
+ # @param alpha [Number]
892
859
  # @return [Color]
893
- # @raise [ArgumentError] if any parameter is the wrong type or out-of
894
- # bounds, or if RGB properties and HSL properties are adjusted at the
895
- # same time
860
+ # @raise [ArgumentError] if `color` is not a color,
861
+ # if any keyword argument is not a percentage between 0% and 100%,
862
+ # if an unexpected keyword argument is given,
863
+ # or if both HSL and RGB properties are given.
896
864
  def scale_color(color, kwargs)
897
- assert_type color, :Color, :color
865
+ assert_type color, :Color
898
866
  with = Sass::Util.map_hash({
899
867
  "red" => 255,
900
868
  "green" => 255,
@@ -927,40 +895,39 @@ module Sass::Script
927
895
  end
928
896
  declare :scale_color, [:color], :var_kwargs => true
929
897
 
930
- # Changes one or more properties of a color. This can change the red, green,
931
- # blue, hue, saturation, value, and alpha properties. The properties are
932
- # specified as keyword arguments, and replace the color's current value for
933
- # that property.
898
+ # Changes one or more properties of a color.
899
+ # This can change the red, green, blue, hue, saturation, value, and alpha properties.
900
+ # The properties are specified as keyword arguments,
901
+ # and replace the color's current value for that property.
934
902
  #
935
- # All properties are optional. You can't specify both RGB properties
936
- # (`$red`, `$green`, `$blue`) and HSL properties (`$hue`, `$saturation`,
937
- # `$value`) at the same time.
903
+ # `$red`, `$green`, and `$blue` properties should be between 0 and 255.
904
+ # `$saturation` and `$lightness` should be between 0% and 100%.
905
+ # `$alpha` should be between 0 and 1.
906
+ #
907
+ # All properties are optional.
908
+ # You can't specify both RGB properties (`$red`, `$green`, `$blue`)
909
+ # and HSL properties (`$hue`, `$saturation`, `$value`) at the same time.
938
910
  #
939
911
  # @example
940
912
  # change-color(#102030, $blue: 5) => #102005
941
913
  # change-color(#102030, $red: 120, $blue: 5) => #782005
942
914
  # change-color(hsl(25, 100%, 80%), $lightness: 40%, $alpha: 0.8) => hsla(25, 100%, 40%, 0.8)
943
- # @overload change_color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])
944
- # @param $color [Color]
945
- # @param $red [Number] The new red component for the color, within 0 and 255
946
- # inclusive
947
- # @param $green [Number] The new green component for the color, within 0 and
948
- # 255 inclusive
949
- # @param $blue [Number] The new blue component for the color, within 0 and
950
- # 255 inclusive
951
- # @param $hue [Number] The new hue component for the color, in degrees
952
- # @param $saturation [Number] The new saturation component for the color,
953
- # between `0%` and `100%` inclusive
954
- # @param $lightness [Number] The new lightness component for the color,
955
- # within `0%` and `100%` inclusive
956
- # @param $alpha [Number] The new alpha component for the color, within 0 and
957
- # 1 inclusive
915
+ # @param color [Color]
916
+ # @param red [Number]
917
+ # @param green [Number]
918
+ # @param blue [Number]
919
+ # @param hue [Number]
920
+ # @param saturation [Number]
921
+ # @param lightness [Number]
922
+ # @param alpha [Number]
958
923
  # @return [Color]
959
- # @raise [ArgumentError] if any parameter is the wrong type or out-of
960
- # bounds, or if RGB properties and HSL properties are adjusted at the
961
- # same time
924
+ # @raise [ArgumentError] if `color` is not a color,
925
+ # if any keyword argument is not a number,
926
+ # if any keyword argument is not in the legal range,
927
+ # if an unexpected keyword argument is given,
928
+ # or if both HSL and RGB properties are given.
962
929
  def change_color(color, kwargs)
963
- assert_type color, :Color, :color
930
+ assert_type color, :Color
964
931
  with = Sass::Util.map_hash(%w[red green blue hue saturation lightness alpha]) do |name, max|
965
932
  next unless val = kwargs.delete(name)
966
933
  assert_type val, :Number, name
@@ -976,32 +943,33 @@ module Sass::Script
976
943
  end
977
944
  declare :change_color, [:color], :var_kwargs => true
978
945
 
979
- # Mixes two colors together. Specifically, takes the average of each of the
980
- # RGB components, optionally weighted by the given percentage. The opacity
981
- # of the colors is also considered when weighting the components.
946
+ # Mixes together two colors.
947
+ # Specifically, takes the average of each of the RGB components,
948
+ # optionally weighted by the given percentage.
949
+ # The opacity of the colors is also considered when weighting the components.
982
950
  #
983
951
  # The weight specifies the amount of the first color that should be included
984
- # in the returned color. The default, `50%`, means that half the first color
985
- # and half the second color should be used. `25%` means that a quarter of
986
- # the first color and three quarters of the second color should be used.
952
+ # in the returned color.
953
+ # The default, 50%, means that half the first color
954
+ # and half the second color should be used.
955
+ # 25% means that a quarter of the first color
956
+ # and three quarters of the second color should be used.
987
957
  #
988
958
  # @example
989
959
  # mix(#f00, #00f) => #7f007f
990
960
  # mix(#f00, #00f, 25%) => #3f00bf
991
961
  # mix(rgba(255, 0, 0, 0.5), #00f) => rgba(63, 0, 191, 0.75)
992
- # @overload mix($color-1, $color-2, $weight: 50%)
993
- # @param $color-1 [Color]
994
- # @param $color-2 [Color]
995
- # @param $weight [Number] The relative weight of each color. Closer to `0%`
996
- # gives more weight to `$color`, closer to `100%` gives more weight to
997
- # `$color2`
998
- # @return [Color]
999
- # @raise [ArgumentError] if `$weight` is out of bounds or any parameter is
1000
- # the wrong type
1001
- def mix(color_1, color_2, weight = Number.new(50))
1002
- assert_type color_1, :Color, :color_1
1003
- assert_type color_2, :Color, :color_2
1004
- assert_type weight, :Number, :weight
962
+ # @overload mix(color1, color2, weight: 50%)
963
+ # @param color1 [Color]
964
+ # @param color2 [Color]
965
+ # @param weight [Number] between 0% and 100%
966
+ # @return [Color]
967
+ # @raise [ArgumentError] if `color1` or `color2` aren't colors,
968
+ # or `weight` isn't a number between 0% and 100%
969
+ def mix(color1, color2, weight = Number.new(50))
970
+ assert_type color1, :Color
971
+ assert_type color2, :Color
972
+ assert_type weight, :Number
1005
973
 
1006
974
  Sass::Util.check_range("Weight", 0..100, weight, '%')
1007
975
 
@@ -1010,11 +978,11 @@ module Sass::Script
1010
978
  # to perform the weighted average of the two RGB values.
1011
979
  #
1012
980
  # It works by first normalizing both parameters to be within [-1, 1],
1013
- # where 1 indicates "only use color_1", -1 indicates "only use color_2", and
981
+ # where 1 indicates "only use color1", -1 indicates "only use color2", and
1014
982
  # all values in between indicated a proportionately weighted average.
1015
983
  #
1016
984
  # Once we have the normalized variables w and a, we apply the formula
1017
- # (w + a)/(1 + w*a) to get the combined weight (in [-1, 1]) of color_1.
985
+ # (w + a)/(1 + w*a) to get the combined weight (in [-1, 1]) of color1.
1018
986
  # This formula has two especially nice properties:
1019
987
  #
1020
988
  # * When either w or a are -1 or 1, the combined weight is also that number
@@ -1022,60 +990,57 @@ module Sass::Script
1022
990
  #
1023
991
  # * When a is 0, the combined weight is w, and vice versa.
1024
992
  #
1025
- # Finally, the weight of color_1 is renormalized to be within [0, 1]
1026
- # and the weight of color_2 is given by 1 minus the weight of color_1.
993
+ # Finally, the weight of color1 is renormalized to be within [0, 1]
994
+ # and the weight of color2 is given by 1 minus the weight of color1.
1027
995
  p = (weight.value/100.0).to_f
1028
996
  w = p*2 - 1
1029
- a = color_1.alpha - color_2.alpha
997
+ a = color1.alpha - color2.alpha
1030
998
 
1031
999
  w1 = (((w * a == -1) ? w : (w + a)/(1 + w*a)) + 1)/2.0
1032
1000
  w2 = 1 - w1
1033
1001
 
1034
- rgb = color_1.rgb.zip(color_2.rgb).map {|v1, v2| v1*w1 + v2*w2}
1035
- alpha = color_1.alpha*p + color_2.alpha*(1-p)
1002
+ rgb = color1.rgb.zip(color2.rgb).map {|v1, v2| v1*w1 + v2*w2}
1003
+ alpha = color1.alpha*p + color2.alpha*(1-p)
1036
1004
  Color.new(rgb + [alpha])
1037
1005
  end
1038
1006
  declare :mix, [:color_1, :color_2]
1039
1007
  declare :mix, [:color_1, :color_2, :weight]
1040
1008
 
1041
- # Converts a color to grayscale. This is identical to `desaturate(color,
1042
- # 100%)`.
1009
+ # Converts a color to grayscale.
1010
+ # This is identical to `desaturate(color, 100%)`.
1043
1011
  #
1044
- # @see #desaturate
1045
- # @overload grayscale($color)
1046
- # @param $color [Color]
1012
+ # @param color [Color]
1047
1013
  # @return [Color]
1048
- # @raise [ArgumentError] if `$color` isn't a color
1014
+ # @raise [ArgumentError] if `color` isn't a color
1015
+ # @see #desaturate
1049
1016
  def grayscale(color)
1050
1017
  return Sass::Script::String.new("grayscale(#{color})") if color.is_a?(Sass::Script::Number)
1051
1018
  desaturate color, Number.new(100)
1052
1019
  end
1053
1020
  declare :grayscale, [:color]
1054
1021
 
1055
- # Returns the complement of a color. This is identical to `adjust-hue(color,
1056
- # 180deg)`.
1022
+ # Returns the complement of a color.
1023
+ # This is identical to `adjust-hue(color, 180deg)`.
1057
1024
  #
1058
- # @see #adjust_hue #adjust-hue
1059
- # @overload complement($color)
1060
- # @param $color [Color]
1025
+ # @param color [Color]
1061
1026
  # @return [Color]
1062
- # @raise [ArgumentError] if `$color` isn't a color
1027
+ # @raise [ArgumentError] if `color` isn't a color
1028
+ # @see #adjust_hue #adjust-hue
1063
1029
  def complement(color)
1064
1030
  adjust_hue color, Number.new(180)
1065
1031
  end
1066
1032
  declare :complement, [:color]
1067
1033
 
1068
- # Returns the inverse (negative) of a color. The red, green, and blue values
1069
- # are inverted, while the opacity is left alone.
1034
+ # Returns the inverse (negative) of a color.
1035
+ # The red, green, and blue values are inverted, while the opacity is left alone.
1070
1036
  #
1071
- # @overload invert($color)
1072
- # @param $color [Color]
1037
+ # @param color [Color]
1073
1038
  # @return [Color]
1074
- # @raise [ArgumentError] if `$color` isn't a color
1039
+ # @raise [ArgumentError] if `color` isn't a color
1075
1040
  def invert(color)
1076
1041
  return Sass::Script::String.new("invert(#{color})") if color.is_a?(Sass::Script::Number)
1077
1042
 
1078
- assert_type color, :Color, :color
1043
+ assert_type color, :Color
1079
1044
  color.with(
1080
1045
  :red => (255 - color.red),
1081
1046
  :green => (255 - color.green),
@@ -1083,17 +1048,16 @@ module Sass::Script
1083
1048
  end
1084
1049
  declare :invert, [:color]
1085
1050
 
1086
- # Removes quotes from a string. If the string is already unquoted, this will
1087
- # return it unmodified.
1051
+ # Removes quotes from a string if the string is quoted,
1052
+ # or returns the same string if it's not.
1088
1053
  #
1054
+ # @param string [String]
1055
+ # @return [String]
1056
+ # @raise [ArgumentError] if `string` isn't a string
1089
1057
  # @see #quote
1090
1058
  # @example
1091
1059
  # unquote("foo") => foo
1092
1060
  # unquote(foo) => foo
1093
- # @overload unquote($string)
1094
- # @param $string [String]
1095
- # @return [String]
1096
- # @raise [ArgumentError] if `$string` isn't a string
1097
1061
  def unquote(string)
1098
1062
  if string.is_a?(Sass::Script::String)
1099
1063
  Sass::Script::String.new(string.value, :identifier)
@@ -1106,21 +1070,20 @@ module Sass::Script
1106
1070
  # Add quotes to a string if the string isn't quoted,
1107
1071
  # or returns the same string if it is.
1108
1072
  #
1073
+ # @param string [String]
1074
+ # @return [String]
1075
+ # @raise [ArgumentError] if `string` isn't a string
1109
1076
  # @see #unquote
1110
1077
  # @example
1111
1078
  # quote("foo") => "foo"
1112
1079
  # quote(foo) => "foo"
1113
- # @overload quote($string)
1114
- # @param $string [String]
1115
- # @return [String]
1116
- # @raise [ArgumentError] if `$string` isn't a string
1117
1080
  def quote(string)
1118
- assert_type string, :String, :string
1081
+ assert_type string, :String
1119
1082
  Sass::Script::String.new(string.value, :string)
1120
1083
  end
1121
1084
  declare :quote, [:string]
1122
1085
 
1123
- # Returns the type of a value.
1086
+ # Inspects the type of the argument, returning it as an unquoted string.
1124
1087
  #
1125
1088
  # @example
1126
1089
  # type-of(100px) => number
@@ -1129,16 +1092,15 @@ module Sass::Script
1129
1092
  # type-of(true) => bool
1130
1093
  # type-of(#fff) => color
1131
1094
  # type-of(blue) => color
1132
- # @overload type_of($value)
1133
- # @param $value [Literal] The value to inspect
1134
- # @return [String] The unquoted string name of the value's type
1095
+ # @param value [Literal] The object to inspect
1096
+ # @return [String] The unquoted string name of the literal's type
1135
1097
  def type_of(value)
1136
1098
  Sass::Script::String.new(value.class.name.gsub(/Sass::Script::/,'').downcase)
1137
1099
  end
1138
1100
  declare :type_of, [:value]
1139
1101
 
1140
- # Returns the unit(s) associated with a number. Complex units are sorted in
1141
- # alphabetical order by numerator and denominator.
1102
+ # Inspects the unit of the number, returning it as a quoted string.
1103
+ # Complex units are sorted in alphabetical order by numerator and denominator.
1142
1104
  #
1143
1105
  # @example
1144
1106
  # unit(100) => ""
@@ -1146,61 +1108,56 @@ module Sass::Script
1146
1108
  # unit(3em) => "em"
1147
1109
  # unit(10px * 5em) => "em*px"
1148
1110
  # unit(10px * 5em / 30cm / 1rem) => "em*px/cm*rem"
1149
- # @overload unit($number)
1150
- # @param $number [Number]
1151
- # @return [String] The unit(s) of the number, as a quoted string
1152
- # @raise [ArgumentError] if `$number` isn't a number
1111
+ # @param number [Literal] The number to inspect
1112
+ # @return [String] The unit(s) of the number
1113
+ # @raise [ArgumentError] if `number` isn't a number
1153
1114
  def unit(number)
1154
- assert_type number, :Number, :number
1115
+ assert_type number, :Number
1155
1116
  Sass::Script::String.new(number.unit_str, :string)
1156
1117
  end
1157
1118
  declare :unit, [:number]
1158
1119
 
1159
- # Returns whether a number has units.
1120
+ # Inspects the unit of the number, returning a boolean indicating if it is unitless.
1160
1121
  #
1161
1122
  # @example
1162
1123
  # unitless(100) => true
1163
1124
  # unitless(100px) => false
1164
- # @overload unitless($number)
1165
- # @param $number [Number]
1166
- # @return [Bool]
1167
- # @raise [ArgumentError] if `$number` isn't a number
1125
+ # @param number [Literal] The number to inspect
1126
+ # @return [Bool] Whether or not the number is unitless
1127
+ # @raise [ArgumentError] if `number` isn't a number
1168
1128
  def unitless(number)
1169
- assert_type number, :Number, :number
1129
+ assert_type number, :Number
1170
1130
  Sass::Script::Bool.new(number.unitless?)
1171
1131
  end
1172
1132
  declare :unitless, [:number]
1173
1133
 
1174
- # Returns whether two numbers can added, subtracted, or compared.
1134
+ # Returns true if two numbers are similar enough to be added, subtracted, or compared.
1175
1135
  #
1176
1136
  # @example
1177
1137
  # comparable(2px, 1px) => true
1178
1138
  # comparable(100px, 3em) => false
1179
1139
  # comparable(10cm, 3mm) => true
1180
- # @overload comparable($number-1, $number-2)
1181
- # @param $number-1 [Number]
1182
- # @param $number-2 [Number]
1183
- # @return [Bool]
1184
- # @raise [ArgumentError] if either parameter is the wrong type
1140
+ # @param number_1 [Number]
1141
+ # @param number_2 [Number]
1142
+ # @return [Bool] indicating if the numbers can be compared.
1143
+ # @raise [ArgumentError] if `number_1` or `number_2` aren't numbers
1185
1144
  def comparable(number_1, number_2)
1186
- assert_type number_1, :Number, :number_1
1187
- assert_type number_2, :Number, :number_2
1145
+ assert_type number_1, :Number
1146
+ assert_type number_2, :Number
1188
1147
  Sass::Script::Bool.new(number_1.comparable_to?(number_2))
1189
1148
  end
1190
1149
  declare :comparable, [:number_1, :number_2]
1191
1150
 
1192
- # Converts a unitless number to a percentage.
1151
+ # Converts a decimal number to a percentage.
1193
1152
  #
1194
1153
  # @example
1195
- # percentage(0.2) => 20%
1196
1154
  # percentage(100px / 50px) => 200%
1197
- # @overload percentage($value)
1198
- # @param $value [Number]
1199
- # @return [Number]
1200
- # @raise [ArgumentError] if `$value` isn't a unitless number
1155
+ # @param value [Number] The decimal number to convert to a percentage
1156
+ # @return [Number] The percentage
1157
+ # @raise [ArgumentError] If `value` isn't a unitless number
1201
1158
  def percentage(value)
1202
1159
  unless value.is_a?(Sass::Script::Number) && value.unitless?
1203
- raise ArgumentError.new("$value: #{value.inspect} is not a unitless number")
1160
+ raise ArgumentError.new("#{value.inspect} is not a unitless number")
1204
1161
  end
1205
1162
  Sass::Script::Number.new(value.value * 100, ['%'])
1206
1163
  end
@@ -1211,83 +1168,76 @@ module Sass::Script
1211
1168
  # @example
1212
1169
  # round(10.4px) => 10px
1213
1170
  # round(10.6px) => 11px
1214
- # @overload round($value)
1215
- # @param $value [Number]
1216
- # @return [Number]
1217
- # @raise [ArgumentError] if `$value` isn't a number
1171
+ # @param value [Number] The number
1172
+ # @return [Number] The rounded number
1173
+ # @raise [ArgumentError] if `value` isn't a number
1218
1174
  def round(value)
1219
1175
  numeric_transformation(value) {|n| n.round}
1220
1176
  end
1221
1177
  declare :round, [:value]
1222
1178
 
1223
- # Rounds a number up to the next whole number.
1179
+ # Rounds a number up to the nearest whole number.
1224
1180
  #
1225
1181
  # @example
1226
1182
  # ceil(10.4px) => 11px
1227
1183
  # ceil(10.6px) => 11px
1228
- # @overload ceil($value)
1229
- # @param $value [Number]
1230
- # @return [Number]
1231
- # @raise [ArgumentError] if `$value` isn't a number
1184
+ # @param value [Number] The number
1185
+ # @return [Number] The rounded number
1186
+ # @raise [ArgumentError] if `value` isn't a number
1232
1187
  def ceil(value)
1233
1188
  numeric_transformation(value) {|n| n.ceil}
1234
1189
  end
1235
1190
  declare :ceil, [:value]
1236
1191
 
1237
- # Rounds a number down to the previous whole number.
1192
+ # Rounds down to the nearest whole number.
1238
1193
  #
1239
1194
  # @example
1240
1195
  # floor(10.4px) => 10px
1241
1196
  # floor(10.6px) => 10px
1242
- # @overload floor($value)
1243
- # @param $value [Number]
1244
- # @return [Number]
1245
- # @raise [ArgumentError] if `$value` isn't a number
1197
+ # @param value [Number] The number
1198
+ # @return [Number] The rounded number
1199
+ # @raise [ArgumentError] if `value` isn't a number
1246
1200
  def floor(value)
1247
1201
  numeric_transformation(value) {|n| n.floor}
1248
1202
  end
1249
1203
  declare :floor, [:value]
1250
1204
 
1251
- # Returns the absolute value of a number.
1205
+ # Finds the absolute value of a number.
1252
1206
  #
1253
1207
  # @example
1254
1208
  # abs(10px) => 10px
1255
1209
  # abs(-10px) => 10px
1256
- # @overload abs($value)
1257
- # @param $value [Number]
1258
- # @return [Number]
1259
- # @raise [ArgumentError] if `$value` isn't a number
1210
+ # @param value [Number] The number
1211
+ # @return [Number] The absolute value
1212
+ # @raise [ArgumentError] if `value` isn't a number
1260
1213
  def abs(value)
1261
1214
  numeric_transformation(value) {|n| n.abs}
1262
1215
  end
1263
1216
  declare :abs, [:value]
1264
1217
 
1265
- # Finds the minimum of several numbers. This function takes any number of
1218
+ # Finds the minimum of several values. This function takes any number of
1266
1219
  # arguments.
1267
1220
  #
1268
1221
  # @example
1269
1222
  # min(1px, 4px) => 1px
1270
1223
  # min(5em, 3em, 4em) => 3em
1271
- # @overload min($numbers...)
1272
- # @param $numbers [[Number]]
1273
- # @return [Number]
1224
+ # @param values [[Number]] The numbers
1225
+ # @return [Number] The minimum value
1274
1226
  # @raise [ArgumentError] if any argument isn't a number, or if not all of
1275
1227
  # the arguments have comparable units
1276
- def min(*numbers)
1277
- numbers.each {|n| assert_type n, :Number}
1278
- numbers.inject {|min, num| min.lt(num).to_bool ? min : num}
1228
+ def min(*values)
1229
+ values.each {|v| assert_type v, :Number}
1230
+ values.inject {|min, val| min.lt(val).to_bool ? min : val}
1279
1231
  end
1280
1232
  declare :min, [], :var_args => :true
1281
1233
 
1282
- # Finds the maximum of several numbers. This function takes any number of
1234
+ # Finds the maximum of several values. This function takes any number of
1283
1235
  # arguments.
1284
1236
  #
1285
1237
  # @example
1286
- # max(1px, 4px) => 4px
1287
- # max(5em, 3em, 4em) => 5em
1288
- # @overload max($numbers...)
1289
- # @param $numbers [[Number]]
1290
- # @return [Number]
1238
+ # max(1px, 4px) => 1px
1239
+ # max(5em, 3em, 4em) => 3em
1240
+ # @return [Number] The maximum value
1291
1241
  # @raise [ArgumentError] if any argument isn't a number, or if not all of
1292
1242
  # the arguments have comparable units
1293
1243
  def max(*values)
@@ -1301,9 +1251,8 @@ module Sass::Script
1301
1251
  # @example
1302
1252
  # length(10px) => 1
1303
1253
  # length(10px 20px 30px) => 3
1304
- # @overload length($list)
1305
- # @param $list [Literal]
1306
- # @return [Number]
1254
+ # @param list [Literal] The list
1255
+ # @return [Number] The length
1307
1256
  def length(list)
1308
1257
  Sass::Script::Number.new(list.to_a.size)
1309
1258
  end
@@ -1311,20 +1260,18 @@ module Sass::Script
1311
1260
 
1312
1261
  # Gets the nth item in a list.
1313
1262
  #
1314
- # Note that unlike some languages, the first item in a Sass list is number
1315
- # 1, the second number 2, and so forth.
1263
+ # Note that unlike some languages, the first item in a Sass list is number 1,
1264
+ # the second number 2, and so forth.
1316
1265
  #
1317
1266
  # @example
1318
1267
  # nth(10px 20px 30px, 1) => 10px
1319
1268
  # nth((Helvetica, Arial, sans-serif), 3) => sans-serif
1320
- # @overload nth($list, $n)
1321
- # @param $list [Literal]
1322
- # @param $n [Number] The index of the item to get
1323
- # @return [Literal]
1324
- # @raise [ArgumentError] if `$n` isn't an integer between 1 and the length
1325
- # of `$list`
1269
+ # @param list [Literal] The list
1270
+ # @param n [Number] The index into the list
1271
+ # @return [Literal] The nth item in the list
1272
+ # @raise [ArgumentError] If `n` isn't an integer between 1 and the list's length.
1326
1273
  def nth(list, n)
1327
- assert_type n, :Number, :n
1274
+ assert_type n, :Number
1328
1275
  if !n.int?
1329
1276
  raise ArgumentError.new("List index #{n} must be an integer")
1330
1277
  elsif n.to_i < 1
@@ -1339,12 +1286,12 @@ module Sass::Script
1339
1286
  end
1340
1287
  declare :nth, [:list, :n]
1341
1288
 
1342
- # Joins together two lists into one.
1289
+ # Joins together two lists into a new list.
1343
1290
  #
1344
- # Unless `$separator` is passed, if one list is comma-separated and one is
1345
- # space-separated, the first parameter's separator is used for the resulting
1346
- # list. If both lists have fewer than two items, spaces are used for the
1347
- # resulting list.
1291
+ # Unless the `$separator` argument is passed,
1292
+ # if one list is comma-separated and one is space-separated,
1293
+ # the first parameter's separator is used for the resulting list.
1294
+ # If the lists have only one item each, spaces are used for the resulting list.
1348
1295
  #
1349
1296
  # @example
1350
1297
  # join(10px 20px, 30px 40px) => 10px 20px 30px 40px
@@ -1352,15 +1299,14 @@ module Sass::Script
1352
1299
  # join(10px, 20px) => 10px 20px
1353
1300
  # join(10px, 20px, comma) => 10px, 20px
1354
1301
  # join((blue, red), (#abc, #def), space) => blue red #abc #def
1355
- # @overload join($list1, $list2, $separator: auto)
1356
- # @param $list1 [Literal]
1357
- # @param $list2 [Literal]
1358
- # @param $separator [String] The list separator to use. If this is `comma`
1359
- # or `space`, that separator will be used. If this is `auto` (the
1360
- # default), the separator is determined as explained above.
1361
- # @return [List]
1302
+ # @overload join(list1, list2, separator: auto)
1303
+ # @param list1 [Literal] The first list to join
1304
+ # @param list2 [Literal] The second list to join
1305
+ # @param separator [String] How the list separator (comma or space) should be determined.
1306
+ # If this is `comma` or `space`, that is always the separator;
1307
+ # if this is `auto` (the default), the separator is determined as explained above.
1362
1308
  def join(list1, list2, separator = Sass::Script::String.new("auto"))
1363
- assert_type separator, :String, :separator
1309
+ assert_type separator, :String
1364
1310
  unless %w[auto space comma].include?(separator.value)
1365
1311
  raise ArgumentError.new("Separator name must be space, comma, or auto")
1366
1312
  end
@@ -1379,7 +1325,8 @@ module Sass::Script
1379
1325
 
1380
1326
  # Appends a single value onto the end of a list.
1381
1327
  #
1382
- # Unless the `$separator` argument is passed, if the list had only one item,
1328
+ # Unless the `$separator` argument is passed,
1329
+ # if the list has only one item,
1383
1330
  # the resulting list will be space-separated.
1384
1331
  #
1385
1332
  # @example
@@ -1388,15 +1335,14 @@ module Sass::Script
1388
1335
  # append(10px 20px, 30px 40px) => 10px 20px (30px 40px)
1389
1336
  # append(10px, 20px, comma) => 10px, 20px
1390
1337
  # append((blue, red), green, space) => blue red green
1391
- # @overload append($list, $val, $separator: auto)
1392
- # @param $list [Literal]
1393
- # @param $val [Literal]
1394
- # @param $separator [String] The list separator to use. If this is `comma`
1395
- # or `space`, that separator will be used. If this is `auto` (the
1396
- # default), the separator is determined as explained above.
1397
- # @return [List]
1338
+ # @overload append(list, val, separator: auto)
1339
+ # @param list [Literal] The list to add the value to
1340
+ # @param val [Literal] The value to add to the end of the list
1341
+ # @param separator [String] How the list separator (comma or space) should be determined.
1342
+ # If this is `comma` or `space`, that is always the separator;
1343
+ # if this is `auto` (the default), the separator is the same as that used by the list.
1398
1344
  def append(list, val, separator = Sass::Script::String.new("auto"))
1399
- assert_type separator, :String, :separator
1345
+ assert_type separator, :String
1400
1346
  unless %w[auto space comma].include?(separator.value)
1401
1347
  raise ArgumentError.new("Separator name must be space, comma, or auto")
1402
1348
  end
@@ -1412,9 +1358,8 @@ module Sass::Script
1412
1358
  declare :append, [:list, :val]
1413
1359
  declare :append, [:list, :val, :separator]
1414
1360
 
1415
- # Combines several lists into a single multidimensional list. The nth value
1416
- # of the resulting list is a space separated list of the source lists' nth
1417
- # values.
1361
+ # Combines several lists into a single comma separated list
1362
+ # space separated lists.
1418
1363
  #
1419
1364
  # The length of the resulting list is the length of the
1420
1365
  # shortest list.
@@ -1422,16 +1367,13 @@ module Sass::Script
1422
1367
  # @example
1423
1368
  # zip(1px 1px 3px, solid dashed solid, red green blue)
1424
1369
  # => 1px solid red, 1px dashed green, 3px solid blue
1425
- # @overload zip($lists...)
1426
- # @param $lists [[Literal]]
1427
- # @return [List]
1428
1370
  def zip(*lists)
1429
1371
  length = nil
1430
1372
  values = []
1431
1373
  lists.each do |list|
1432
- array = list.to_a
1433
- values << array.dup
1434
- length = length.nil? ? array.length : [length, array.length].min
1374
+ assert_type list, :List
1375
+ values << list.value.dup
1376
+ length = length.nil? ? list.value.length : [length, list.value.length].min
1435
1377
  end
1436
1378
  values.each do |value|
1437
1379
  value.slice!(length)
@@ -1442,22 +1384,15 @@ module Sass::Script
1442
1384
  declare :zip, [], :var_args => true
1443
1385
 
1444
1386
 
1445
- # Returns the position of a value within a list. If the value isn't found,
1446
- # returns false instead.
1447
- #
1448
- # Note that unlike some languages, the first item in a Sass list is number
1449
- # 1, the second number 2, and so forth.
1387
+ # Returns the position of the given value within the given
1388
+ # list. If not found, returns false.
1450
1389
  #
1451
1390
  # @example
1452
1391
  # index(1px solid red, solid) => 2
1453
1392
  # index(1px solid red, dashed) => false
1454
- # @overload index($list, $value)
1455
- # @param $list [Literal]
1456
- # @param $value [Literal]
1457
- # @return [Number, Bool] The 1-based index of `$value` in `$list`, or
1458
- # `false`
1459
1393
  def index(list, value)
1460
- index = list.to_a.index {|e| e.eq(value).to_bool }
1394
+ assert_type list, :List
1395
+ index = list.value.index {|e| e.eq(value).to_bool }
1461
1396
  if index
1462
1397
  Number.new(index + 1)
1463
1398
  else
@@ -1466,19 +1401,14 @@ module Sass::Script
1466
1401
  end
1467
1402
  declare :index, [:list, :value]
1468
1403
 
1469
- # Returns one of two values, depending on whether or not `$condition` is
1470
- # true. Just like in `@if`, all values other than `false` and `null` are
1471
- # considered to be true.
1404
+ # Returns one of two values based on the truth value of the first argument.
1472
1405
  #
1473
1406
  # @example
1474
1407
  # if(true, 1px, 2px) => 1px
1475
1408
  # if(false, 1px, 2px) => 2px
1476
- # @overload if($condition, $if-true, $if-false)
1477
- # @param $condition [Literal] Whether the `$if-true` or `$if-false` will be
1478
- # returned
1479
- # @param $if-true [Literal]
1480
- # @param $if-false [Literal]
1481
- # @return [Literal] `$if-true` or `$if-false`
1409
+ # @param condition [Bool] Whether the first or second value will be returned.
1410
+ # @param if_true [Literal] The value that will be returned if `$condition` is true.
1411
+ # @param if_false [Literal] The value that will be returned if `$condition` is false.
1482
1412
  def if(condition, if_true, if_false)
1483
1413
  if condition.to_bool
1484
1414
  if_true
@@ -1488,49 +1418,19 @@ module Sass::Script
1488
1418
  end
1489
1419
  declare :if, [:condition, :if_true, :if_false]
1490
1420
 
1491
- # This function only exists as a workaround for IE7's [`content: counter`
1492
- # bug][bug]. It works identically to any other plain-CSS function, except it
1493
- # avoids adding spaces between the argument commas.
1494
- #
1495
- # [bug]: http://jes.st/2013/ie7s-css-breaking-content-counter-bug/
1496
- #
1497
- # @example
1498
- # counter(item, ".") => counter(item,".")
1499
- # @overload counter($args...)
1500
- # @return [String]
1501
- def counter(*args)
1502
- Sass::Script::String.new("counter(#{args.map {|a| a.to_s(options)}.join(',')})")
1503
- end
1504
- declare :counter, [], :var_args => true
1505
-
1506
- # This function only exists as a workaround for IE7's [`content: counters`
1507
- # bug][bug]. It works identically to any other plain-CSS function, except it
1508
- # avoids adding spaces between the argument commas.
1509
- #
1510
- # [bug]: http://jes.st/2013/ie7s-css-breaking-content-counter-bug/
1511
- #
1512
- # @example
1513
- # counters(item, ".") => counters(item,".")
1514
- # @overload counters($args...)
1515
- # @return [String]
1516
- def counters(*args)
1517
- Sass::Script::String.new("counters(#{args.map {|a| a.to_s(options)}.join(',')})")
1518
- end
1519
- declare :counters, [], :var_args => true
1520
-
1521
1421
  private
1522
1422
 
1523
1423
  # This method implements the pattern of transforming a numeric value into
1524
1424
  # another numeric value with the same units.
1525
1425
  # It yields a number to a block to perform the operation and return a number
1526
1426
  def numeric_transformation(value)
1527
- assert_type value, :Number, :value
1427
+ assert_type value, :Number
1528
1428
  Sass::Script::Number.new(yield(value.value), value.numerator_units, value.denominator_units)
1529
1429
  end
1530
1430
 
1531
1431
  def _adjust(color, amount, attr, range, op, units = "")
1532
- assert_type color, :Color, :color
1533
- assert_type amount, :Number, :amount
1432
+ assert_type color, :Color
1433
+ assert_type amount, :Number
1534
1434
  Sass::Util.check_range('Amount', range, amount, units)
1535
1435
 
1536
1436
  # TODO: is it worth restricting here,