Class: CssVariable

Inherits:
Object show all
Defined in:
lib/jirametrics/css_variable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject (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

#inspectObject



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_sObject



22
23
24
# File 'lib/jirametrics/css_variable.rb', line 22

def to_s
  "var(#{@name})"
end