Class: VisualAttributes

Inherits:
Attributes
  • Object
show all
Defined in:
lib/domle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, parent: nil) ⇒ VisualAttributes

Returns a new instance of VisualAttributes.



32
33
34
35
# File 'lib/domle.rb', line 32

def initialize(x, parent: nil)
  @callback = parent
  self.merge! x if x
end

Instance Attribute Details

#callbackObject (readonly)

Returns the value of attribute callback.



30
31
32
# File 'lib/domle.rb', line 30

def callback
  @callback
end

Instance Method Details

#style(parent = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/domle.rb', line 37

def style(parent=nil)
  
  @callback ||= parent
  
  if @style.nil? then

    h = self[:style].split(';').inject({}) do |r, x|
      k, v = x.split(':',2).map(&:strip)
      r.merge(k.to_sym => v)
    end

    @style = Style.new(self, h)

  end
  @style
end