Class: JsDuck::Videos
- Inherits:
-
GroupedAsset
- Object
- GroupedAsset
- JsDuck::Videos
- Defined in:
- lib/jsduck/videos.rb
Overview
Reads in videos JSON file
Class Method Summary collapse
-
.create(filename) ⇒ Object
Parses videos config file.
Instance Method Summary collapse
-
#add_names_if_missing ⇒ Object
Each video should have a name, which is used in URL to reference the video.
-
#icon_url(video) ⇒ Object
Extracts video icon URL from video hash.
-
#initialize(filename) ⇒ Videos
constructor
A new instance of Videos.
Methods inherited from GroupedAsset
#[], #build_map_by_name, #each_item, #map_items, #to_array
Constructor Details
Class Method Details
.create(filename) ⇒ Object
Parses videos config file
10 11 12 13 14 15 16 |
# 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 |
Instance Method Details
#add_names_if_missing ⇒ Object
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.
27 28 29 30 31 |
# 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) ⇒ Object
Extracts video icon URL from video hash
34 35 36 |
# File 'lib/jsduck/videos.rb', line 34 def icon_url(video) video["thumb"] end |