Sha256: 52d95a6b715c838e22f239fd7ae9c214e05d9ef6af622638a9e9d2241f12fff3
Contents?: true
Size: 1.65 KB
Versions: 5
Compression:
Stored size: 1.65 KB
Contents
require 'rhet-butler/yaml-type' module RhetButler class SlideGroup < YamlType include Enumerable register "group" class <<self def optional_config %w[type slide_type html_class html_classes html_id] end def required_config %w[slides] end end def setup_defaults @html_id = nil @html_classes = ["group"] @slides = [] @metadata = {} end def normalize_config(coder) case coder.type when :map coder.map when :scalar raise "A slide group needs to at least be a list of slides" when :seq { 'slides' => coder.seq} end end def configure value_from_config("html_id") do |value| @html_id = value end value_from_config("html_classes") do |value| @html_classes += [*value] end value_from_config("html_class") do |value| @html_classes << value end @slides = @config_hash.delete('slides') @metadata = @config_hash end attr_accessor :slides attr_reader :metadata, :html_classes def each if block_given? @slides.each{|slide| yield(slide)} else @slides.each end end def each_slide if block_given? @slides.each do |slide| if slide.is_a? SlideGroup slide.each_slide{|sl| yield sl} else yield slide end end else enum_for :each_slide end end def template_name "group.html" end def id_attr if @html_id.nil? return "" else "id='#@html_id'" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems