Class: AnimateIt::EmbedBuilder
- Inherits:
-
Object
- Object
- AnimateIt::EmbedBuilder
- Defined in:
- lib/animate_it/embed_helper.rb
Instance Attribute Summary collapse
-
#composition ⇒ Object
readonly
Returns the value of attribute composition.
Instance Method Summary collapse
- #chapter_navigation(**attributes, &block) ⇒ Object
-
#initialize(view, composition, navigation: {}) ⇒ EmbedBuilder
constructor
A new instance of EmbedBuilder.
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 = end |
Instance Attribute Details
#composition ⇒ Object (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 (**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 |