Class: PhlexUI::Avatar::Builder

Inherits:
Base
  • Object
show all
Defined in:
lib/phlex_ui/avatar/builder.rb

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#before_template

Constructor Details

#initialize(size: :md, src: nil, alt: nil, initials: nil, **attrs) ⇒ Builder

Returns a new instance of Builder.



5
6
7
8
9
10
11
# File 'lib/phlex_ui/avatar/builder.rb', line 5

def initialize(size: :md, src: nil, alt: nil, initials: nil, **attrs)
  @size = size
  @src = src
  @alt = alt
  @initials = initials
  super(**attrs)
end

Instance Method Details

#view_templateObject



13
14
15
16
17
18
# File 'lib/phlex_ui/avatar/builder.rb', line 13

def view_template
  render PhlexUI::Avatar.new(size: @size, **attrs) do
    render_image if @src
    render_initials if @initials
  end
end