Sha256: 101d0bebd78e0b16e4ff0c555da106777ceb0d3c3332ae4d86051e9cd4efb1dd

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module SlideHero
  class Slide
    attr_reader :headline, :headline_size, :transition
    def initialize(headline, headline_size: :large, transition: :default, &point_block)
      @headline = headline
      @headline_size = headline_size
      @transition = transition
      instance_eval(&point_block) if block_given?
    end

    def compile
      gem_path = Gem.loaded_specs['slide_hero'].full_gem_path
      Tilt::ERBTemplate.new(File.join(gem_path, 
                                      'lib/slide_hero/views/slide.html.erb')).
                                      render(self)
    end

    def point(text, animation: nil)
      points << Point.new(text, animation: animation).compile
    end

    def list(style=:unordered, &block)
      points << List.new(style, &block).compile
    end

    def code(*args, &code)
      points << Code.new(*args, &code).compile
    end

    def points
      @points ||= []
    end

    def note(text)
      points << Note.new(text).compile
    end

    def image(*args, **kwargs)
      points << Image.new(*args, **kwargs).compile
    end

    def media(*args, **kwargs)
      points << Media.new(*args, **kwargs).compile
    end

    private
    def size_to_markup
      { 
        large: :h1,
        medium: :h2,
        small: :h3
      }[headline_size]
    end

    def data_attributes
      "data-transition=\"#{transition}\""
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slide_hero-0.0.3 lib/slide_hero/slide.rb