lib/sass/selector/abstract_sequence.rb in sass-3.2.0.alpha.74 vs lib/sass/selector/abstract_sequence.rb in sass-3.2.0.alpha.75
- 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
@@ -61,9 +62,17 @@
# Whether or not this selector sequence contains a placeholder selector.
# Checks recursively.
def has_placeholder?
@has_placeholder ||=
members.any? {|m| m.is_a?(AbstractSequence) ? m.has_placeholder? : m.is_a?(Placeholder)}
+ end
+
+ # 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