class Bootstrap4RailsComponents::Bootstrap::Components::Embed

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

Public Instance Methods

aspect_ratio() click to toggle source
# 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
autoplay() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/embed.rb, line 22
def autoplay
  options.fetch(:autoplay, default_autoplay)
end
iframe() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/embed.rb, line 13
def iframe
  return unless iframe?
  view_context.content_tag :iframe, nil, src: src, class: 'embed-responsive-item', allowfullscreen: true
end
iframe?() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/embed.rb, line 18
def iframe?
  options[:iframe].present?
end
render() { |: body)| ... } click to toggle source
# 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

Private Instance Methods

allowed_aspect_ratios() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/embed.rb, line 52
def allowed_aspect_ratios
  %w[21:9 16:9 4:3 1:1]
end
component_css_class() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/embed.rb, line 38
def component_css_class
  'embed-responsive'
end
css_classes() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/embed.rb, line 47
def css_classes
  return super unless allowed_aspect_ratios.include?(aspect_ratio)
  super + " embed-responsive-#{aspect_ratio.gsub("\:", 'by')}"
end
default_aspect_ratio() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/embed.rb, line 56
def default_aspect_ratio
  '16:9'
end
default_autoplay() click to toggle source

def defaults

super.merge!(iframe: default_iframe,
             aspect_ratio: default_aspect_ratio,
             autoplay: default_autoplay)

end

# File lib/bootstrap4_rails_components/bootstrap/components/embed.rb, line 74
def default_autoplay
  false
end
non_html_attribute_options() click to toggle source

def default_iframe

''

end

# File lib/bootstrap4_rails_components/bootstrap/components/embed.rb, line 64
def non_html_attribute_options
  super.push(:iframe, :aspect_ratio, :autoplay)
end
src() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/embed.rb, line 42
def src
  return unless iframe?
  options[:iframe] + (autoplay ? '?autoplay=1' : '')
end