Class: Stylesheet::CssRule
- Inherits:
-
Object
- Object
- Stylesheet::CssRule
- Defined in:
- lib/stylesheet/css_rule.rb
Direct Known Subclasses
CssCharsetRule, CssFontFaceRule, CssImportRule, CssMediaRule, CssNullRule, CssStyleRule
Constant Summary collapse
- NULL_RULE =
0
- STYLE_RULE =
1
- CHARSET_RULE =
2
- IMPORT_RULE =
3
- MEDIA_RULE =
4
- FONT_FACE_RULE =
5
Class Attribute Summary collapse
-
.rule_classes ⇒ Object
readonly
Returns the value of attribute rule_classes.
Instance Attribute Summary collapse
-
#css_text ⇒ Object
readonly
Returns the value of attribute css_text.
-
#parent_rule ⇒ Object
readonly
Returns the value of attribute parent_rule.
-
#parent_style_sheet ⇒ Object
readonly
Returns the value of attribute parent_style_sheet.
- #type ⇒ Object
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ CssRule
constructor
A new instance of CssRule.
- #matches_rule? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(args) ⇒ CssRule
Returns a new instance of CssRule.
33 34 35 36 37 38 |
# File 'lib/stylesheet/css_rule.rb', line 33 def initialize(args) @parent_style_sheet = args[:parent_style_sheet] @parent_rule = args[:parent_rule] @css_text = args[:css_text] parse_css_text end |
Class Attribute Details
.rule_classes ⇒ Object (readonly)
Returns the value of attribute rule_classes.
16 17 18 |
# File 'lib/stylesheet/css_rule.rb', line 16 def rule_classes @rule_classes end |
Instance Attribute Details
#css_text ⇒ Object (readonly)
Returns the value of attribute css_text.
11 12 13 |
# File 'lib/stylesheet/css_rule.rb', line 11 def css_text @css_text end |
#parent_rule ⇒ Object (readonly)
Returns the value of attribute parent_rule.
11 12 13 |
# File 'lib/stylesheet/css_rule.rb', line 11 def parent_rule @parent_rule end |
#parent_style_sheet ⇒ Object (readonly)
Returns the value of attribute parent_style_sheet.
11 12 13 |
# File 'lib/stylesheet/css_rule.rb', line 11 def parent_style_sheet @parent_style_sheet end |
#type ⇒ Object
40 41 42 |
# File 'lib/stylesheet/css_rule.rb', line 40 def type raise NotImplementedError end |
Class Method Details
.factory(args) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/stylesheet/css_rule.rb', line 25 def self.factory(args) rule = CssRule.rule_classes.find do |klass| klass.matches_rule?(args[:css_text]) end rule.new(args) if rule end |
.inherited(subclass) ⇒ Object
21 22 23 |
# File 'lib/stylesheet/css_rule.rb', line 21 def self.inherited(subclass) CssRule.rule_classes << subclass end |
Instance Method Details
#matches_rule? ⇒ Boolean
44 45 46 |
# File 'lib/stylesheet/css_rule.rb', line 44 def matches_rule? false end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/stylesheet/css_rule.rb', line 48 def to_s "#<#{self.class.name} css_text:#{css_text}>" end |