Class: CssVariable
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name) ⇒ CssVariable
constructor
A new instance of CssVariable.
- #inspect ⇒ Object
- #to_json(*_args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ CssVariable
Returns a new instance of CssVariable.
14 15 16 |
# File 'lib/jirametrics/css_variable.rb', line 14 def initialize name @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/jirametrics/css_variable.rb', line 4 def name @name end |
Class Method Details
.[](name) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/jirametrics/css_variable.rb', line 6 def self.[](name) if name.start_with? '--' CssVariable.new name else name end end |
Instance Method Details
#==(other) ⇒ Object
30 31 32 |
# File 'lib/jirametrics/css_variable.rb', line 30 def == other self.class == other.class && @name == other.name end |
#inspect ⇒ Object
26 27 28 |
# File 'lib/jirametrics/css_variable.rb', line 26 def inspect "CssVariable['#{@name}']" end |
#to_json(*_args) ⇒ Object
18 19 20 |
# File 'lib/jirametrics/css_variable.rb', line 18 def to_json(*_args) "getComputedStyle(document.body).getPropertyValue('#{@name}')" end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/jirametrics/css_variable.rb', line 22 def to_s "var(#{@name})" end |