Class: Xomponent::Style
- Inherits:
-
Object
- Object
- Xomponent::Style
- Defined in:
- lib/Xomponent/Style.rb
Instance Attribute Summary collapse
-
#s ⇒ Object
writeonly
Sets the attribute s.
Instance Method Summary collapse
- #add(selector, styles) ⇒ Object
-
#initialize ⇒ Style
constructor
A new instance of Style.
- #render ⇒ Object
- #reset! ⇒ Object
Constructor Details
#initialize ⇒ Style
Returns a new instance of Style.
4 5 6 |
# File 'lib/Xomponent/Style.rb', line 4 def initialize @s = '' end |
Instance Attribute Details
#s=(value) ⇒ Object (writeonly)
Sets the attribute s
3 4 5 |
# File 'lib/Xomponent/Style.rb', line 3 def s=(value) @s = value end |
Instance Method Details
#add(selector, styles) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/Xomponent/Style.rb', line 12 def add(selector, styles) styles_str = styles.map do |name, value| "#{name}:#{value}" end.join(';') @s += "#{selector}{#{styles_str}}" end |
#render ⇒ Object
20 21 22 |
# File 'lib/Xomponent/Style.rb', line 20 def render @s end |
#reset! ⇒ Object
8 9 10 |
# File 'lib/Xomponent/Style.rb', line 8 def reset! @s = "body{margin:0;font-family:sans-serif}" end |