class MCMarkdown::Formatter::Wistia::WistiaFormatter

Public Instance Methods

video(attributes={}) click to toggle source
# File lib/mc_markdown/formatters/wistia.rb, line 17
def video attributes={}
  wistia_id = attributes.delete(:id)
  options = defaults.merge(attributes)

  query_params = options.map do |attr,value|
    # camel case attribute names
    camel_case = attr.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
    "#{camel_case}=#{value}"
  end

  html_params = {
    src: "http://fast.wistia.com/embed/iframe/#{wistia_id}?#{query_params.join('&')}",
    allowtransparency: 'true',
    frameborder: '0',
    scrolling: 'no',
    class: 'wistia_embed',
    name: 'wistia_embed',
    width: options[:video_width],
    height: options[:video_height]
  }

  if wistia_id
    "<iframe #{render_params( html_params )}></iframe>"
  else
    ""
  end
end

Private Instance Methods

defaults() click to toggle source
# File lib/mc_markdown/formatters/wistia.rb, line 47
def defaults
  {
    version: "v1",
    video_width: 600,
    video_height: 400,
    controls_visible_on_load: true
  }
end
render_params(params) click to toggle source
# File lib/mc_markdown/formatters/wistia.rb, line 56
def render_params params
  params.map { |attr, value| "#{attr}='#{value}'" }.join(' ')
end