Class: Sass::Selector::Attribute

Inherits:
Simple
  • Object
show all
Defined in:
lib/sass/selector.rb

Overview

An attribute selector (e.g. [href^="http://"]).

Instance Attribute Summary collapse

Attributes inherited from Simple

#filename, #line

Instance Method Summary collapse

Methods inherited from Simple

#eql?, #hash, #inspect, #unify, #unify_namespaces

Constructor Details

#initialize(name, namespace, operator, value) ⇒ Attribute

Returns a new instance of Attribute.

Parameters:



263
264
265
266
267
268
# File 'lib/sass/selector.rb', line 263

def initialize(name, namespace, operator, value)
  @name = name
  @namespace = namespace
  @operator = operator
  @value = value
end

Instance Attribute Details

#nameArray<String, Sass::Script::Node> (readonly)

The attribute name.

Returns:



239
240
241
# File 'lib/sass/selector.rb', line 239

def name
  @name
end

#namespaceArray<String, Sass::Script::Node>? (readonly)

The attribute namespace. nil means the default namespace, [""] means no namespace, ["*"] means any namespace.

Returns:



247
248
249
# File 'lib/sass/selector.rb', line 247

def namespace
  @namespace
end

#operatorString (readonly)

The matching operator, e.g. "=" or "^=".

Returns:

  • (String)


252
253
254
# File 'lib/sass/selector.rb', line 252

def operator
  @operator
end

#valueArray<String, Sass::Script::Node> (readonly)

The right-hand side of the operator.

Returns:



257
258
259
# File 'lib/sass/selector.rb', line 257

def value
  @value
end

Instance Method Details

#to_a

See Also:

  • Selector#to_a


271
272
273
274
275
276
277
# File 'lib/sass/selector.rb', line 271

def to_a
  res = ["["]
  res.concat(@namespace) << "|" if @namespace
  res.concat @name
  (res << @operator).concat @value if @value
  res << "]"
end