class JsDuck::Videos
Reads in videos JSON file
Public Class Methods
create(filename)
click to toggle source
Parses videos config file
# File lib/jsduck/videos.rb, line 10 def self.create(filename) if filename Videos.new(filename) else Util::NullObject.new(:to_array => [], :[] => nil) end end
new(filename)
click to toggle source
# File lib/jsduck/videos.rb, line 18 def initialize(filename) @groups = Util::Json.read(filename) add_names_if_missing build_map_by_name end
Public Instance Methods
add_names_if_missing()
click to toggle source
Each video should have a name, which is used in URL to reference the video. For backwards compatibility, when name is missing, we turn the “id” (that must exist) into a name.
# File lib/jsduck/videos.rb, line 27 def add_names_if_missing each_item do |video| video["name"] = video["id"] unless video["name"] end end
icon_url(video)
click to toggle source
Extracts video icon URL from video hash
# File lib/jsduck/videos.rb, line 34 def icon_url(video) video["thumb"] end