Sha256: 3f03664b4e81337c8c34cf516af5d960f75f77824e00cef48cdb47c476036075

Contents?: true

Size: 774 Bytes

Versions: 6

Compression:

Stored size: 774 Bytes

Contents

require 'jsduck/json_duck'
require 'jsduck/null_object'

module JsDuck

  # Reads in videos JSON file
  class Videos
    # Parses videos config file
    def self.create(filename)
      if filename
        Videos.new(filename)
      else
        NullObject.new(:to_array => [])
      end
    end

    def initialize(filename)
      @videos = JsonDuck.read(filename)
    end

    # Writes videos JSON file to a dir
    def write(dir)
      FileUtils.mkdir(dir) unless File.exists?(dir)
      # Write the JSON to output dir, so it's available in released
      # version of docs and people can use it with JSDuck by themselves.
      JsonDuck.write_json(dir+"/videos.json", @videos)
    end

    # Returns all videos as array
    def to_array
      @videos
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jsduck-3.4.1 lib/jsduck/videos.rb
jsduck-3.4.0 lib/jsduck/videos.rb
jsduck-3.3.1 lib/jsduck/videos.rb
jsduck-3.3.0 lib/jsduck/videos.rb
jsduck-3.2.1 lib/jsduck/videos.rb
jsduck-3.1.0 lib/jsduck/videos.rb