Class: Attributes

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent: nil) ⇒ Attributes

Returns a new instance of Attributes.



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

def initialize(parent: nil)
  @callback = parent
end

Instance Attribute Details

#callbackObject (readonly)

Returns the value of attribute callback.



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

def callback
  @callback
end

Instance Method Details

#style(parent = nil) ⇒ Object



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

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