class SlideHero::Slide

Attributes

background[R]
headline[R]
headline_size[R]
transition[R]

Public Class Methods

new(headline=nil, headline_size: :medium, transition: :default, background: nil, &point_block) click to toggle source
# File lib/slide_hero/slide.rb, line 7
def initialize(headline=nil, headline_size: :medium, transition: :default, background: nil, &point_block)
  @headline = headline
  @headline_size = headline_size
  @transition = transition

  @background= background
  instance_eval(&point_block) if block_given?
end

Public Instance Methods

points() click to toggle source
# File lib/slide_hero/slide.rb, line 18
def points
  @points ||= []
end

Private Instance Methods

data_attributes() click to toggle source
# File lib/slide_hero/slide.rb, line 31
def data_attributes
  "data-transition=\"#{transition}\"".tap do |attr|
    case
    when String(background).start_with?('http')
      attr << " data-background=\"#{background}\""
    when String(background).include?('.')
      filename = background.gsub(/\s/, "%20")
      attr << " data-background=\"/images/#{filename}\""
    when background
      attr << " data-background=\"#{background}\""
    end
  end
end
size_to_markup() click to toggle source
# File lib/slide_hero/slide.rb, line 23
def size_to_markup
  {
    large: :h1,
    medium: :h2,
    small: :h3
  }[headline_size]
end