Class: Habaki::Rules
Instance Method Summary
collapse
#each_match, #each_matching_rule, #find_matching_declarations, #find_matching_rules, #index_selectors!, #lookup_rules
Methods inherited from NodeArray
#string_join, #to_s
Instance Method Details
#add_by_selector(selector_str) ⇒ StyleRule
add rule by selectors string
166
167
168
169
170
171
|
# File 'lib/habaki/rules.rb', line 166
def add_by_selector(selector_str)
rule = StyleRule.new
rule.selectors = Selectors.parse(selector_str)
push rule
rule
end
|
129
130
131
|
# File 'lib/habaki/rules.rb', line 129
def charset
enum_with_class(CharsetRule).first
end
|
#each_rule(&block) ⇒ Object
186
187
188
|
# File 'lib/habaki/rules.rb', line 186
def each_rule(&block)
each(&block)
end
|
#enum_with_class(klass) ⇒ Enumerator<Rule>
120
121
122
123
124
125
126
|
# File 'lib/habaki/rules.rb', line 120
def enum_with_class(klass)
Enumerator.new do |rules|
each do |rule|
rules << rule if rule.is_a?(klass)
end
end
end
|
#find_by_selector(selector_str) ⇒ Array<Rule>
find rules from selector str
176
177
178
179
180
181
182
183
184
|
# File 'lib/habaki/rules.rb', line 176
def find_by_selector(selector_str)
results = []
each do |rule|
rule.each_selector do |selector|
results << rule if selector_str == selector.to_s
end
end
results
end
|
#font_faces ⇒ Enumerator<FontFaceRule>
149
150
151
|
# File 'lib/habaki/rules.rb', line 149
def font_faces
enum_with_class(FontFaceRule)
end
|
134
135
136
|
# File 'lib/habaki/rules.rb', line 134
def medias
enum_with_class(MediaRule)
end
|
144
145
146
|
# File 'lib/habaki/rules.rb', line 144
def namespaces
enum_with_class(NamespaceRule)
end
|
#pages ⇒ Enumerator<PageRule>
154
155
156
|
# File 'lib/habaki/rules.rb', line 154
def pages
enum_with_class()
end
|
#read_from_katana(rules) ⇒ 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.
199
200
201
202
203
|
# File 'lib/habaki/rules.rb', line 199
def read_from_katana(rules)
rules.each do |rule|
push read_rule(rule)
end
end
|
#string(format = Formatter::Base.new) ⇒ String
192
193
194
|
# File 'lib/habaki/rules.rb', line 192
def string(format = Formatter::Base.new)
"#{format.rules_prefix}#{string_join(format, format.rules_join)}"
end
|
#styles ⇒ Enumerator<StyleRule>
159
160
161
|
# File 'lib/habaki/rules.rb', line 159
def styles
enum_with_class(StyleRule)
end
|
139
140
141
|
# File 'lib/habaki/rules.rb', line 139
def supports
enum_with_class(SupportsRule)
end
|