Class: NfgUi::Bootstrap::Components::Embed

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

Overview

Bootstrap Responsive Embed Component

Direct Known Subclasses

Components::Elements::Embed

Instance Attribute Summary

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Instance Method Details

#aspect_ratioObject



8
9
10
# File 'lib/nfg_ui/bootstrap/components/embed.rb', line 8

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

#autoplayObject



21
22
23
# File 'lib/nfg_ui/bootstrap/components/embed.rb', line 21

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

#iframeObject



12
13
14
15
# File 'lib/nfg_ui/bootstrap/components/embed.rb', line 12

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

#iframe?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/nfg_ui/bootstrap/components/embed.rb', line 17

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

#renderObject



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

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