Class: HS::Element

Inherits:
Object
  • Object
show all
Includes:
ElementPreview
Defined in:
lib/hs/elements/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ElementPreview

#element_preview, #text_preview

Constructor Details

#initialize(args = {}) ⇒ Element

Returns a new instance of Element.



12
13
14
15
16
17
18
# File 'lib/hs/elements/element.rb', line 12

def initialize(args = {})
  args.each do |key, val|
    instance_variable_set("@#{key}", val)
  end

  @children ||= []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



9
10
11
# File 'lib/hs/elements/element.rb', line 9

def children
  @children
end

#class_nameObject

Returns the value of attribute class_name.



10
11
12
# File 'lib/hs/elements/element.rb', line 10

def class_name
  @class_name
end

#styleObject

Returns the value of attribute style.



10
11
12
# File 'lib/hs/elements/element.rb', line 10

def style
  @style
end

Instance Method Details

#paramsObject



24
25
26
27
28
29
30
31
# File 'lib/hs/elements/element.rb', line 24

def params
  params = {}
  class_name = element_class_name
  params[:class] = class_name if class_name
  params[:style] = style if style

  params
end

#previewObject



33
34
35
# File 'lib/hs/elements/element.rb', line 33

def preview
  element_preview(tag_name, params, children)
end

#tag_nameObject



20
21
22
# File 'lib/hs/elements/element.rb', line 20

def tag_name
  'div'
end