Class: Hatemile::Util::Css::Rcp::RCPRule
- Inherits:
-
StyleSheetRule
- Object
- StyleSheetRule
- Hatemile::Util::Css::Rcp::RCPRule
- Defined in:
- lib/hatemile/util/css/rcp/rcp_rule.rb
Overview
The RCPRule class is official implementation of Hatemile::Util::Css::StyleSheetRule for Ruby CSS Parser.
Instance Method Summary collapse
- #get_declarations(property_name) ⇒ Object
- #get_selector ⇒ Object
- #has_declarations? ⇒ Boolean
- #has_property?(property_name) ⇒ Boolean
-
#initialize(rule) ⇒ RCPRule
constructor
Initializes a new object that encapsulate the Ruby CSS Parser rule.
Constructor Details
#initialize(rule) ⇒ RCPRule
Initializes a new object that encapsulate the Ruby CSS Parser rule.
43 44 45 46 47 48 |
# File 'lib/hatemile/util/css/rcp/rcp_rule.rb', line 43 def initialize(rule) Hatemile::Helper.require_not_nil(rule) Hatemile::Helper.require_valid_type(rule, CssParser::RuleSet) @rule = rule end |
Instance Method Details
#get_declarations(property_name) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/hatemile/util/css/rcp/rcp_rule.rb', line 67 def get_declarations(property_name) declarations = [] @rule.each_declaration do |property, value, _important| if property == property_name declarations.push(RCPDeclaration.new(property, value)) end end declarations end |
#get_selector ⇒ Object
79 80 81 |
# File 'lib/hatemile/util/css/rcp/rcp_rule.rb', line 79 def get_selector @rule.selectors.join(', ') end |
#has_declarations? ⇒ Boolean
61 62 63 |
# File 'lib/hatemile/util/css/rcp/rcp_rule.rb', line 61 def has_declarations? true end |
#has_property?(property_name) ⇒ Boolean
52 53 54 55 56 57 |
# File 'lib/hatemile/util/css/rcp/rcp_rule.rb', line 52 def has_property?(property_name) @rule.each_declaration do |property, _value, _important| return true if property == property_name end false end |