lib/sass/selector/abstract_sequence.rb in sass-3.1.15 vs lib/sass/selector/abstract_sequence.rb in sass-3.1.16
- old
+ new
@@ -1,11 +1,12 @@
module Sass
module Selector
# The abstract parent class of the various selector sequence classes.
#
- # All subclasses should implement a `members` method
- # that returns an array of object that respond to `#line=` and `#filename=`.
+ # All subclasses should implement a `members` method that returns an array
+ # of object that respond to `#line=` and `#filename=`, as well as a `to_a`
+ # method that returns an array of strings and script nodes.
class AbstractSequence
# The line of the Sass template on which this selector was declared.
#
# @return [Fixnum]
attr_reader :line
@@ -55,8 +56,16 @@
# @return [Boolean] Whether or not this is equal to `other`
def eql?(other)
other.class == self.class && other.hash == self.hash && _eql?(other)
end
alias_method :==, :eql?
+
+ # Converts the selector into a string. This is the standard selector
+ # string, along with any SassScript interpolation that may exist.
+ #
+ # @return [String]
+ def to_s
+ to_a.map {|e| e.is_a?(Sass::Script::Node) ? "\#{#{e.to_sass}}" : e}.join
+ end
end
end
end