Class: Bemer::Entity

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

Direct Known Subclasses

EntityBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block = '', element = nil, **options, &content) ⇒ Entity



13
14
15
16
17
18
19
20
21
# File 'lib/bemer/entity.rb', line 13

def initialize(block = '', element = nil, **options, &content)
  @bem_class = Bemer.bem_class(block, element)
  @block     = block
  @content   = extract_content(options.delete(:content), &content)
  @elem      = element
  @name      = Bemer.entity_name(block, element)

  extract_options!(options)
end

Instance Attribute Details

#bemObject (readonly)

Returns the value of attribute bem.



9
10
11
# File 'lib/bemer/entity.rb', line 9

def bem
  @bem
end

#bem_cascadeObject

Returns the value of attribute bem_cascade.



8
9
10
# File 'lib/bemer/entity.rb', line 8

def bem_cascade
  @bem_cascade
end

#bem_classObject (readonly)

Returns the value of attribute bem_class.



9
10
11
# File 'lib/bemer/entity.rb', line 9

def bem_class
  @bem_class
end

#blockObject (readonly)

Returns the value of attribute block.



9
10
11
# File 'lib/bemer/entity.rb', line 9

def block
  @block
end

#contentObject (readonly)

Returns the value of attribute content.



9
10
11
# File 'lib/bemer/entity.rb', line 9

def content
  @content
end

#elemObject (readonly) Also known as: element

Returns the value of attribute elem.



9
10
11
# File 'lib/bemer/entity.rb', line 9

def elem
  @elem
end

#jsObject (readonly)

Returns the value of attribute js.



9
10
11
# File 'lib/bemer/entity.rb', line 9

def js
  @js
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/bemer/entity.rb', line 9

def name
  @name
end

#tagObject (readonly)

Returns the value of attribute tag.



9
10
11
# File 'lib/bemer/entity.rb', line 9

def tag
  @tag
end

Instance Method Details

#attrsObject



23
24
25
# File 'lib/bemer/entity.rb', line 23

def attrs
  @attrs ||= build_attrs(html_attrs)
end

#block?Boolean



27
28
29
# File 'lib/bemer/entity.rb', line 27

def block?
  !element?
end

#clsObject



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

def cls
  @cls ||= build_css_classes(css_classes)
end

#elem?Boolean Also known as: element?



35
36
37
# File 'lib/bemer/entity.rb', line 35

def elem?
  !elem.nil?
end

#mixObject



41
42
43
# File 'lib/bemer/entity.rb', line 41

def mix
  @mix ||= mixins.to_a
end

#modsObject



45
46
47
# File 'lib/bemer/entity.rb', line 45

def mods
  @mods ||= modifiers.to_h
end