Class: Spud::Videos::VideoTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Spud::Videos::VideoTag
- Includes:
- ActionView::Context, ActionView::Helpers, SpudVideosHelper
- Defined in:
- lib/spud_videos/liquid_tags.rb
Instance Method Summary collapse
-
#initialize(tag_name, params, tokens) ⇒ VideoTag
constructor
A new instance of VideoTag.
- #parse_params(params) ⇒ Object
- #render(context) ⇒ Object
- #tag_name ⇒ Object
- #tag_value ⇒ Object
Methods included from SpudVideosHelper
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) = {} @params[1..-1].each do |param| if !param.blank? args = param.to_s.split("=") if args[0].downcase == 'width' [:width] = args[1] elsif args[0].downcase == 'height' [:height] = args[1] end end end return spud_video(@video,) end |
#tag_name ⇒ Object
21 22 23 |
# File 'lib/spud_videos/liquid_tags.rb', line 21 def tag_name return 'video' end |
#tag_value ⇒ Object
25 26 27 |
# File 'lib/spud_videos/liquid_tags.rb', line 25 def tag_value return @video.name end |