Class: DOM::Style
Overview
Style
Instance Method Summary collapse
-
#[](prop) ⇒ String
Gets a CSS property value.
-
#[]=(prop, value) ⇒ Object
Sets the given CSS property with the given value.
-
#initialize(el) ⇒ Style
constructor
Initializes the style.
-
#method_missing(name, value) ⇒ String
Sets or gets a given CSS property.
Constructor Details
#initialize(el) ⇒ Style
Initializes the style
7 8 9 |
# File 'opal/fron/dom/style.rb', line 7 def initialize(el) @el = el end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, value) ⇒ String
Sets or gets a given CSS property
17 18 19 20 21 22 23 |
# File 'opal/fron/dom/style.rb', line 17 def method_missing(name, value) if name =~ /\=$/ self[name[0..-2]] = value else self[name] end end |
Instance Method Details
#[](prop) ⇒ String
Gets a CSS property value
30 31 32 |
# File 'opal/fron/dom/style.rb', line 30 def [](prop) `#{@el}.style[#{prop}]` end |
#[]=(prop, value) ⇒ Object
Sets the given CSS property with the given value
38 39 40 |
# File 'opal/fron/dom/style.rb', line 38 def []=(prop, value) `#{@el}.style[#{prop}] = #{value}` end |