Class: ColorParser::Stylesheet
- Inherits:
-
Object
- Object
- ColorParser::Stylesheet
- Defined in:
- lib/color_parser/stylesheet.rb
Instance Method Summary collapse
- #bg_colors ⇒ Object
- #border_colors ⇒ Object
-
#colors ⇒ Object
gst list of colors from styles.
-
#initialize(style_sheet) ⇒ Stylesheet
constructor
A new instance of Stylesheet.
-
#properties ⇒ Object
split up selectors into properties, and return property key/value pairs.
- #rules ⇒ Object
- #text_colors ⇒ Object
Constructor Details
#initialize(style_sheet) ⇒ Stylesheet
Returns a new instance of Stylesheet.
5 6 7 |
# File 'lib/color_parser/stylesheet.rb', line 5 def initialize(style_sheet) @style_sheet = style_sheet end |
Instance Method Details
#bg_colors ⇒ Object
14 15 16 |
# File 'lib/color_parser/stylesheet.rb', line 14 def bg_colors @bg_colors ||= parse_colors(bg_properties) end |
#border_colors ⇒ Object
22 23 24 |
# File 'lib/color_parser/stylesheet.rb', line 22 def border_colors @border_colors ||= parse_colors(border_properties) end |
#colors ⇒ Object
gst list of colors from styles
10 11 12 |
# File 'lib/color_parser/stylesheet.rb', line 10 def colors @colors ||= parse_colors(color_properties) end |
#properties ⇒ Object
split up selectors into properties, and return property key/value pairs
40 41 42 43 44 45 46 47 48 |
# File 'lib/color_parser/stylesheet.rb', line 40 def properties properties = [] rules.values.each do |declarations| declarations.each {|property, value| properties << [property, value] } end properties end |
#rules ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/color_parser/stylesheet.rb', line 26 def rules rules = {} ([@style_sheet] + style_sheets).each do |css| css.style_rules.each do |rule| rules[rule.selector_text] ||= {} rules[rule.selector_text].merge!(rule.style.declarations) end end rules end |
#text_colors ⇒ Object
18 19 20 |
# File 'lib/color_parser/stylesheet.rb', line 18 def text_colors @text_colors ||= parse_colors(text_properties) end |