Class: MCMarkdown::Formatter::Wistia::WistiaFormatter

Inherits:
Parser::Formatter show all
Defined in:
lib/mc_markdown/formatters/wistia.rb

Instance Method Summary collapse

Methods inherited from Parser::Formatter

#format

Instance Method Details

#video(attributes = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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