Class: AnimateIt::EmbedBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/animate_it/embed_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, composition, navigation: {}) ⇒ EmbedBuilder

Returns a new instance of EmbedBuilder.



7
8
9
10
11
# File 'lib/animate_it/embed_helper.rb', line 7

def initialize(view, composition, navigation: {})
  @view = view
  @composition = composition
  @navigation = navigation
end

Instance Attribute Details

#compositionObject (readonly)

Returns the value of attribute composition.



5
6
7
# File 'lib/animate_it/embed_helper.rb', line 5

def composition
  @composition
end

Instance Method Details

#chapter_navigation(**attributes, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/animate_it/embed_helper.rb', line 13

def chapter_navigation(**attributes, &block)
  custom = block.present?
  preset = if attributes.key?(:preset)
             attributes.delete(:preset)
           elsif !custom
             @navigation.fetch(:preset, :pills)
           end
  mobile = if attributes.key?(:mobile)
             attributes.delete(:mobile)
           elsif !custom
             @navigation[:mobile]
           end
  style = ["--animate-it-chapter-count: #{@composition.chapters.count}", attributes.delete(:style)].compact.join(";")
  ChapterNavigationBuilder.new(@view, @composition, interactive: true, preset:, mobile:, frame: 0)
                          .render(**attributes, style:, &block)
end