Sha256: 5f34ee0ae8eee768847f94d55295939787c4a5eae2cc03529c3969dae7bb8495

Contents?: true

Size: 760 Bytes

Versions: 13

Compression:

Stored size: 760 Bytes

Contents

# encoding: utf-8
module Middleman
  module Presentation
    module Transformers
      # Group slides together
      class GroupSlides
        private

        attr_reader :template

        public

        def initialize(template:)
          @template = template
        end

        def transform(slides)
          groups = Set.new

          new_slides = slides.map do |slide|
            if slide.group && groups.none? { |g| g.name == slide.group }
              slide = group = SlideGroup.new name: slide.group, slides: slides.select { |s| s.group? slide.group }, template: template
              groups << group
            end

            slide
          end

          new_slides - groups.map(&:slides).flatten
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
middleman-presentation-core-0.17.7 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.17.6 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.17.5 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.17.2 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.17.1 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.17.0 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.16.3 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.16.2 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.16.0 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.16.0.rc2 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.16.0.rc1 lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.16.0.beta lib/middleman-presentation-core/transformers/group_slides.rb
middleman-presentation-core-0.16.0.alpha lib/middleman-presentation-core/transformers/group_slides.rb