Class: StyleCop::Selector
- Inherits:
-
Object
- Object
- StyleCop::Selector
- Defined in:
- lib/style_cop/selector.rb
Constant Summary collapse
- EXCLUDED_KEYS =
["width", "height", "top", "bottom", "right", "left"]
Instance Method Summary collapse
-
#initialize(selector) ⇒ Selector
constructor
A new instance of Selector.
- #key ⇒ Object
- #representation ⇒ Object
Constructor Details
#initialize(selector) ⇒ Selector
Returns a new instance of Selector.
5 6 7 |
# File 'lib/style_cop/selector.rb', line 5 def initialize(selector) @selector = selector end |
Instance Method Details
#key ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/style_cop/selector.rb', line 9 def key if selector['class'] ".#{selector['class'].gsub(' ', '.')}" elsif selector['id'] "##{selector['id']}" else selector.tag_name end end |
#representation ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/style_cop/selector.rb', line 19 def representation clean_key = key.gsub(".style-cop-pattern", "") return { clean_key => computed_style } if children.empty? children_hash = children.map(&:representation).inject({}) { |hash, h| hash.merge!(h) } Hash[children_hash.map { |key, value| ["#{clean_key} #{key}", value] }].merge( clean_key => computed_style ) end |