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, #to_s, #unify, #unify_namespaces

Constructor Details

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

Returns a new instance of Attribute.

Parameters:



322
323
324
325
326
327
328
# File 'lib/sass/selector.rb', line 322

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

Instance Attribute Details

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

Flags for the attribute selector (e.g. i).

Returns:



315
316
317
# File 'lib/sass/selector.rb', line 315

def flags
  @flags
end

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

The attribute name.

Returns:



292
293
294
# File 'lib/sass/selector.rb', line 292

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:



300
301
302
# File 'lib/sass/selector.rb', line 300

def namespace
  @namespace
end

#operatorString (readonly)

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

Returns:

  • (String)


305
306
307
# File 'lib/sass/selector.rb', line 305

def operator
  @operator
end

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

The right-hand side of the operator.

Returns:



310
311
312
# File 'lib/sass/selector.rb', line 310

def value
  @value
end

Instance Method Details

#specificity



341
342
343
# File 'lib/sass/selector.rb', line 341

def specificity
  SPECIFICITY_BASE
end

#to_a

See Also:

  • Selector#to_a


331
332
333
334
335
336
337
338
# File 'lib/sass/selector.rb', line 331

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