Class: Sass::Selector::CommaSequence
- Inherits:
-
AbstractSequence
- Object
- AbstractSequence
- Sass::Selector::CommaSequence
- Defined in:
- /var/www/sass-pages/.sass/lib/sass/selector/comma_sequence.rb
Overview
A comma-separated sequence of selectors.
Instance Attribute Summary
- - (Array<Sequence>) members readonly The comma-separated selector sequences represented by this class.
Instance Method Summary
- - (CommaSequence) do_extend(extends) Non-destrucively extends this selector with the extensions specified in a hash (which should come from Sass::Tree::Visitors::Cssize).
- - (CommaSequence) initialize(seqs) constructor A new instance of CommaSequence.
- - (String) inspect Returns a string representation of the sequence.
- - (CommaSequence) resolve_parent_refs(super_cseq) Resolves the Parent selectors within this selector by replacing them with the given parent selector, handling commas appropriately.
- - to_a
Methods inherited from AbstractSequence
Constructor Details
- (CommaSequence) initialize(seqs)
A new instance of CommaSequence
12 13 14 |
# File '/var/www/sass-pages/.sass/lib/sass/selector/comma_sequence.rb', line 12
def initialize(seqs)
@members = seqs
end
|
Instance Attribute Details
- (Array<Sequence>) members (readonly)
The comma-separated selector sequences represented by this class.
9 10 11 |
# File '/var/www/sass-pages/.sass/lib/sass/selector/comma_sequence.rb', line 9
def members
@members
end
|
Instance Method Details
- (CommaSequence) do_extend(extends)
TODO:
Link this to the reference documentation on @extend when such a thing exists.
Non-destrucively extends this selector with the extensions specified in a hash (which should come from Sass::Tree::Visitors::Cssize).
51 52 53 |
# File '/var/www/sass-pages/.sass/lib/sass/selector/comma_sequence.rb', line 51
def do_extend(extends)
CommaSequence.new(members.map {|seq| seq.do_extend(extends)}.flatten)
end
|
- (String) inspect
Returns a string representation of the sequence. This is basically the selector string.
59 60 61 |
# File '/var/www/sass-pages/.sass/lib/sass/selector/comma_sequence.rb', line 59
def inspect
members.map {|m| m.inspect}.join(", ")
end
|
- (CommaSequence) resolve_parent_refs(super_cseq)
Resolves the Parent selectors within this selector by replacing them with the given parent selector, handling commas appropriately.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File '/var/www/sass-pages/.sass/lib/sass/selector/comma_sequence.rb', line 23
def resolve_parent_refs(super_cseq)
if super_cseq.nil?
if @members.any? do |sel|
sel.members.any? do |sel_or_op|
sel_or_op.is_a?(SimpleSequence) && sel_or_op.members.any? {|ssel| ssel.is_a?(Parent)}
end
end
raise Sass::SyntaxError.new("Base-level rules cannot contain the parent-selector-referencing character '&'.")
end
return self
end
CommaSequence.new(
super_cseq.members.map do |super_seq|
@members.map {|seq| seq.resolve_parent_refs(super_seq)}
end.flatten)
end
|
- to_a
64 65 66 67 68 |
# File '/var/www/sass-pages/.sass/lib/sass/selector/comma_sequence.rb', line 64
def to_a
arr = Sass::Util.intersperse(@members.map {|m| m.to_a}, ", ").flatten
arr.delete("\n")
arr
end
|