Class: Spud::Videos::VideoTag

Inherits:
Liquid::Tag
  • Object
show all
Includes:
ActionView::Context, ActionView::Helpers, SpudVideosHelper
Defined in:
lib/spud_videos/liquid_tags.rb

Instance Method Summary collapse

Methods included from SpudVideosHelper

#spud_video

Constructor Details

#initialize(tag_name, params, tokens) ⇒ VideoTag

Returns a new instance of VideoTag.



12
13
14
15
# File 'lib/spud_videos/liquid_tags.rb', line 12

def initialize(tag_name, params, tokens)
  @params = parse_params params
  @video = SpudVideo.find_by_identifier(@params[0])
end

Instance Method Details

#parse_params(params) ⇒ Object



17
18
19
# File 'lib/spud_videos/liquid_tags.rb', line 17

def parse_params(params)
  CSV.parse_line params, {:col_sep => ' '}
end

#render(context) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/spud_videos/liquid_tags.rb', line 29

def render(context)
  options = {}
  @params[1..-1].each do |param|
    if !param.blank?
      args = param.to_s.split("=")
      if args[0].downcase == 'width'
        options[:width] = args[1]
      elsif args[0].downcase == 'height'
        options[:height] = args[1]
      end
    end


  end
  return spud_video(@video,options)
end

#tag_nameObject



21
22
23
# File 'lib/spud_videos/liquid_tags.rb', line 21

def tag_name
  return 'video'
end

#tag_valueObject



25
26
27
# File 'lib/spud_videos/liquid_tags.rb', line 25

def tag_value
  return @video.name
end