Class: Dommy::CSSRule
- Inherits:
-
Object
- Object
- Dommy::CSSRule
- Defined in:
- lib/dommy/css.rb
Overview
‘CSSRule` — opaque wrapper over the raw rule text. Real engines have a subclass hierarchy (CSSStyleRule, CSSMediaRule, etc.), but without a CSS parser we keep one minimal type that round-trips the source text.
Constant Summary collapse
- STYLE_RULE =
1- CHARSET_RULE =
2- IMPORT_RULE =
3- MEDIA_RULE =
4- FONT_FACE_RULE =
5- PAGE_RULE =
6- KEYFRAMES_RULE =
7- KEYFRAME_RULE =
8
Instance Attribute Summary collapse
-
#parent_style_sheet ⇒ Object
readonly
Returns the value of attribute parent_style_sheet.
Instance Method Summary collapse
- #__js_get__(key) ⇒ Object
- #__js_set__(key, value) ⇒ Object
- #css_text ⇒ Object
- #css_text=(v) ⇒ Object
-
#initialize(css_text, parent_style_sheet = nil) ⇒ CSSRule
constructor
A new instance of CSSRule.
- #parent_rule ⇒ Object
-
#type ⇒ Object
We don’t parse, so report the generic STYLE_RULE type.
Constructor Details
#initialize(css_text, parent_style_sheet = nil) ⇒ CSSRule
Returns a new instance of CSSRule.
223 224 225 226 |
# File 'lib/dommy/css.rb', line 223 def initialize(css_text, parent_style_sheet = nil) @css_text = css_text.to_s @parent_style_sheet = parent_style_sheet end |
Instance Attribute Details
#parent_style_sheet ⇒ Object (readonly)
Returns the value of attribute parent_style_sheet.
221 222 223 |
# File 'lib/dommy/css.rb', line 221 def parent_style_sheet @parent_style_sheet end |
Instance Method Details
#__js_get__(key) ⇒ Object
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/dommy/css.rb', line 245 def __js_get__(key) case key when "cssText" @css_text when "type" type when "parentStyleSheet" @parent_style_sheet when "parentRule" parent_rule when "STYLE_RULE" STYLE_RULE when "MEDIA_RULE" MEDIA_RULE when "IMPORT_RULE" IMPORT_RULE when "FONT_FACE_RULE" FONT_FACE_RULE when "PAGE_RULE" PAGE_RULE when "KEYFRAMES_RULE" KEYFRAMES_RULE when "KEYFRAME_RULE" KEYFRAME_RULE when "CHARSET_RULE" CHARSET_RULE end end |
#__js_set__(key, value) ⇒ Object
274 275 276 277 278 279 280 281 |
# File 'lib/dommy/css.rb', line 274 def __js_set__(key, value) case key when "cssText" self.css_text = value end nil end |
#css_text ⇒ Object
228 229 230 |
# File 'lib/dommy/css.rb', line 228 def css_text @css_text end |
#css_text=(v) ⇒ Object
232 233 234 |
# File 'lib/dommy/css.rb', line 232 def css_text=(v) @css_text = v.to_s end |
#parent_rule ⇒ Object
241 242 243 |
# File 'lib/dommy/css.rb', line 241 def parent_rule nil end |
#type ⇒ Object
We don’t parse, so report the generic STYLE_RULE type.
237 238 239 |
# File 'lib/dommy/css.rb', line 237 def type STYLE_RULE end |