Class: Habaki::StyleRule

Inherits:
Rule show all
Defined in:
lib/habaki/style_rule.rb

Overview

CSS style rule selectors + declarations

Instance Attribute Summary collapse

Attributes inherited from Rule

#stylesheet

Instance Method Summary collapse

Methods inherited from Rule

#each_declaration, #each_selector, #rules

Methods inherited from Node

#to_s

Constructor Details

#initializeStyleRule



9
10
11
12
# File 'lib/habaki/style_rule.rb', line 9

def initialize
  @selectors = Selectors.new
  @declarations = Declarations.new
end

Instance Attribute Details

#declarationsDeclarations



7
8
9
# File 'lib/habaki/style_rule.rb', line 7

def declarations
  @declarations
end

#selectorsSelectors



5
6
7
# File 'lib/habaki/style_rule.rb', line 5

def selectors
  @selectors
end

Instance Method Details

#element_match?(element) ⇒ Boolean

does rule match Visitor::Element ?



17
18
19
# File 'lib/habaki/style_rule.rb', line 17

def element_match?(element)
  selectors.element_match?(element)
end

#read_from_katana(rule) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



30
31
32
33
# File 'lib/habaki/style_rule.rb', line 30

def read_from_katana(rule)
  @selectors = Selectors.read_from_katana(rule.selectors)
  @declarations = Declarations.read_from_katana(rule.declarations)
end

#string(format = Formatter::Base.new) ⇒ String



23
24
25
# File 'lib/habaki/style_rule.rb', line 23

def string(format = Formatter::Base.new)
  "#{@selectors.string(format)} {#{format.declarations_prefix}#{@declarations.string(format+1)}#{format.declarations_suffix}#{format.rules_prefix}}"
end