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
161
162
163
164
165
166
|
# File 'lib/habaki/rules.rb', line 161
def add_by_selector(selector_str)
rule = StyleRule.new
rule.selectors = Selectors.parse(selector_str)
push rule
rule
end
|
124
125
126
|
# File 'lib/habaki/rules.rb', line 124
def charset
enum_with_class(CharsetRule).first
end
|
#each_rule(&block) ⇒ Object
181
182
183
|
# File 'lib/habaki/rules.rb', line 181
def each_rule(&block)
each(&block)
end
|
#enum_with_class(klass) ⇒ Enumerator<Rule>
115
116
117
118
119
120
121
|
# File 'lib/habaki/rules.rb', line 115
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
171
172
173
174
175
176
177
178
179
|
# File 'lib/habaki/rules.rb', line 171
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>
144
145
146
|
# File 'lib/habaki/rules.rb', line 144
def font_faces
enum_with_class(FontFaceRule)
end
|
129
130
131
|
# File 'lib/habaki/rules.rb', line 129
def medias
enum_with_class(MediaRule)
end
|
139
140
141
|
# File 'lib/habaki/rules.rb', line 139
def namespaces
enum_with_class(NamespaceRule)
end
|
#pages ⇒ Enumerator<PageRule>
149
150
151
|
# File 'lib/habaki/rules.rb', line 149
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.
194
195
196
197
198
|
# File 'lib/habaki/rules.rb', line 194
def read_from_katana(rules)
rules.each do |rule|
push read_rule(rule)
end
end
|
#string(format = Formatter::Base.new) ⇒ String
187
188
189
|
# File 'lib/habaki/rules.rb', line 187
def string(format = Formatter::Base.new)
"#{format.rules_prefix}#{string_join(format, format.rules_join)}"
end
|
#styles ⇒ Enumerator<StyleRule>
154
155
156
|
# File 'lib/habaki/rules.rb', line 154
def styles
enum_with_class(StyleRule)
end
|
134
135
136
|
# File 'lib/habaki/rules.rb', line 134
def supports
enum_with_class(SupportsRule)
end
|