Path: | lib/sass/util.rb |
Last Update: | Thu Sep 15 15:42:24 -0400 2011 |
A version of `Enumerable#enum_cons` that works in Ruby 1.8 and 1.9.
@param enum [Enumerable] The enumerable to get the enumerator for @param n [Fixnum] The size of each cons @return [Enumerator] The consed enumerator
A version of `Enumerable#enum_slice` that works in Ruby 1.8 and 1.9.
@param enum [Enumerable] The enumerable to get the enumerator for @param n [Fixnum] The size of each slice @return [Enumerator] The consed enumerator
A version of `Enumerable#enum_with_index` that works in Ruby 1.8 and 1.9.
@param enum [Enumerable] The enumerable to get the enumerator for @return [Enumerator] The with-index enumerator
Checks to see if a class has a given method. For example:
Sass::Util.has?(:public_instance_method, String, :gsub) #=> true
Method collections like `Class#instance_methods` return strings in Ruby 1.8 and symbols in Ruby 1.9 and on, so this handles checking for them in a compatible way.
@param attr [to_s] The (singular) name of the method-collection method
(e.g. `:instance_methods`, `:private_methods`)
@param klass [Module] The class to check the methods of which to check @param method [String, Symbol] The name of the method do check for @return [Boolean] Whether or not the given collection has the given method
Like `Object#inspect`, but preserves non-ASCII characters rather than escaping them under Ruby 1.9.2. This is necessary so that the precompiled Haml template can be `encode`d into `@options[:encoding]` before being evaluated.
@param obj {Object} @return {String}
Returns the ASCII code of the given character.
@param c [String] All characters but the first are ignored. @return [Fixnum] The ASCII code of `c`.
Tests the hash-equality of two sets in a cross-version manner. Aggravatingly, this is order-dependent in Ruby 1.8.6.
@param set1 [Set] @param set2 [Set] @return [Boolean] Whether or not the sets are hashcode equal