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
178
179
180
181
182
183
|
# File 'lib/habaki/rules.rb', line 178
def add_by_selector(selector_str)
rule = StyleRule.new
rule.selectors = Selectors.parse(selector_str)
push rule
rule
end
|
141
142
143
|
# File 'lib/habaki/rules.rb', line 141
def charset
enum_with_class(CharsetRule).first
end
|
#each_rule(&block) ⇒ Object
198
199
200
|
# File 'lib/habaki/rules.rb', line 198
def each_rule(&block)
each(&block)
end
|
#enum_with_class(klass) ⇒ Enumerator<Rule>
132
133
134
135
136
137
138
|
# File 'lib/habaki/rules.rb', line 132
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
188
189
190
191
192
193
194
195
196
|
# File 'lib/habaki/rules.rb', line 188
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>
161
162
163
|
# File 'lib/habaki/rules.rb', line 161
def font_faces
enum_with_class(FontFaceRule)
end
|
146
147
148
|
# File 'lib/habaki/rules.rb', line 146
def medias
enum_with_class(MediaRule)
end
|
156
157
158
|
# File 'lib/habaki/rules.rb', line 156
def namespaces
enum_with_class(NamespaceRule)
end
|
#pages ⇒ Enumerator<PageRule>
166
167
168
|
# File 'lib/habaki/rules.rb', line 166
def pages
enum_with_class(PageRule)
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.
211
212
213
214
215
|
# File 'lib/habaki/rules.rb', line 211
def read_from_katana(rules)
rules.each do |rule|
push read_rule(rule)
end
end
|
#string(format = Formatter::Base.new) ⇒ String
204
205
206
|
# File 'lib/habaki/rules.rb', line 204
def string(format = Formatter::Base.new)
"#{format.rules_prefix}#{string_join(format, format.rules_join)}"
end
|
#styles ⇒ Enumerator<StyleRule>
171
172
173
|
# File 'lib/habaki/rules.rb', line 171
def styles
enum_with_class(StyleRule)
end
|
151
152
153
|
# File 'lib/habaki/rules.rb', line 151
def supports
enum_with_class(SupportsRule)
end
|