Class: NfgUi::Bootstrap::Components::CarouselIndicators

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

Overview

Bootstrap Carousel Indicators Component getbootstrap.com/docs/4.1/components/carousel/#with-indicators

Instance Attribute Summary

Attributes inherited from Base

#options, #view_context

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Instance Method Details

#activeObject



9
10
11
# File 'lib/nfg_ui/bootstrap/components/carousel_indicators.rb', line 9

def active
  options.fetch(:active, 1) # allow nil so that no indicator is active if desired
end

#bodyObject

Carousel Indicators do not accept a body



14
15
16
# File 'lib/nfg_ui/bootstrap/components/carousel_indicators.rb', line 14

def body
  nil
end


26
27
28
# File 'lib/nfg_ui/bootstrap/components/carousel_indicators.rb', line 26

def carousel
  options.fetch(:carousel, nil)
end

#component_familyObject



18
19
20
# File 'lib/nfg_ui/bootstrap/components/carousel_indicators.rb', line 18

def component_family
  :carousel
end

#countObject



22
23
24
# File 'lib/nfg_ui/bootstrap/components/carousel_indicators.rb', line 22

def count
  options[:count] || 0 # return 0 when nil
end

#renderObject



30
31
32
33
34
35
36
37
38
# File 'lib/nfg_ui/bootstrap/components/carousel_indicators.rb', line 30

def render
  super do
    capture do
      count.times do |i|
        concat((:li, nil, class: ('active' if active == i + 1), data: { target: carousel, slide_to: i }))
      end
    end
  end
end