Class: Bootstrap4RailsComponents::Bootstrap::Components::Embed

Inherits:
Base
  • Object
show all
Defined in:
lib/bootstrap4_rails_components/bootstrap/components/embed.rb

Overview

Bootstrap Responsive Embed Component getbootstrap.com/docs/4.1/utilities/embed/

Instance Attribute Summary

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods inherited from Base

#component_family, #component_initialize, #data, #href, #html_options, #id, #initialize, #style, #utility_initialize

Constructor Details

This class inherits a constructor from Bootstrap4RailsComponents::Bootstrap::Components::Base

Instance Method Details

#aspect_ratioObject



9
10
11
# File 'lib/bootstrap4_rails_components/bootstrap/components/embed.rb', line 9

def aspect_ratio
  options.fetch(:aspect_ratio, default_aspect_ratio) || default_aspect_ratio
end

#autoplayObject



22
23
24
# File 'lib/bootstrap4_rails_components/bootstrap/components/embed.rb', line 22

def autoplay
  options.fetch(:autoplay, default_autoplay)
end

#iframeObject



13
14
15
16
# File 'lib/bootstrap4_rails_components/bootstrap/components/embed.rb', line 13

def iframe
  return unless iframe?
  view_context. :iframe, nil, src: src, class: 'embed-responsive-item', allowfullscreen: true
end

#iframe?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/bootstrap4_rails_components/bootstrap/components/embed.rb', line 18

def iframe?
  options[:iframe].present?
end

#renderObject



26
27
28
29
30
31
32
33
34
# File 'lib/bootstrap4_rails_components/bootstrap/components/embed.rb', line 26

def render
  super do
    if iframe?
      iframe
    else
      (block_given? ? yield : body)
    end
  end
end