class NfgUi::Bootstrap::Components::Embed
Public Instance Methods
aspect_ratio()
click to toggle source
# File lib/nfg_ui/bootstrap/components/embed.rb, line 8 def aspect_ratio options.fetch(:aspect_ratio, default_aspect_ratio) || default_aspect_ratio end
autoplay()
click to toggle source
# File lib/nfg_ui/bootstrap/components/embed.rb, line 21 def autoplay options.fetch(:autoplay, default_autoplay) end
iframe()
click to toggle source
# File lib/nfg_ui/bootstrap/components/embed.rb, line 12 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/nfg_ui/bootstrap/components/embed.rb, line 17 def iframe? options[:iframe].present? end
render() { |: body)| ... }
click to toggle source
Calls superclass method
NfgUi::Bootstrap::Components::Base#render
# 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
Private Instance Methods
allowed_aspect_ratios()
click to toggle source
# File lib/nfg_ui/bootstrap/components/embed.rb, line 51 def allowed_aspect_ratios %w[21:9 16:9 9:16 4:3 3:4 1:1] end
component_css_class()
click to toggle source
# File lib/nfg_ui/bootstrap/components/embed.rb, line 37 def component_css_class 'embed-responsive' end
css_classes()
click to toggle source
Calls superclass method
NfgUi::Bootstrap::Components::Base#css_classes
# File lib/nfg_ui/bootstrap/components/embed.rb, line 46 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/nfg_ui/bootstrap/components/embed.rb, line 55 def default_aspect_ratio '16:9' end
default_autoplay()
click to toggle source
# File lib/nfg_ui/bootstrap/components/embed.rb, line 63 def default_autoplay false end
non_html_attribute_options()
click to toggle source
Calls superclass method
NfgUi::Bootstrap::Components::Base#non_html_attribute_options
# File lib/nfg_ui/bootstrap/components/embed.rb, line 59 def non_html_attribute_options super.push(:iframe, :aspect_ratio, :autoplay) end
src()
click to toggle source
# File lib/nfg_ui/bootstrap/components/embed.rb, line 41 def src return unless iframe? options[:iframe] + (autoplay ? '?autoplay=1' : '') end