Class: SmTranscript::Metadata
- Inherits:
-
Object
- Object
- SmTranscript::Metadata
- Defined in:
- lib/sm_transcript/metadata.rb
Instance Method Summary collapse
-
#boilerplate ⇒ Object
write_datajs().
- #id_from_time ⇒ Object
-
#initialize(metadata) ⇒ Metadata
constructor
“dc-abstract” “dc-contributor” “dc-creator” “dc-description” “dc-isPartOf” “dc-language” “dc-license” “dc-subject” “dc-title” “dc-audience” “dc-available” “dc-created” “dc-extent” “dc-identifier” “dc-isReplacedBy” “dc-issued” “dc-modified” “dc-publisher” “dc-replaces” “dc-rightsHolder” “dc-spatial” “dc-temporal” “dc-type” “dc-valid”.
-
#write_datajs(dest_file) ⇒ Object
While the format this method writes is JSON, it writes a data.js-like file for compatibility with the IIHS demo player.
Constructor Details
#initialize(metadata) ⇒ Metadata
“dc-abstract”
"dc-contributor"
"dc-creator"
"dc-description"
"dc-isPartOf"
"dc-language"
"dc-license"
"dc-subject"
"dc-title"
"dc-audience"
"dc-available"
"dc-created"
"dc-extent"
"dc-identifier"
"dc-isReplacedBy"
"dc-issued"
"dc-modified"
"dc-publisher"
"dc-replaces"
"dc-rightsHolder"
"dc-spatial"
"dc-temporal"
"dc-type"
"dc-valid"
38 39 40 |
# File 'lib/sm_transcript/metadata.rb', line 38 def initialize() @metadata = end |
Instance Method Details
#boilerplate ⇒ Object
write_datajs()
84 85 86 |
# File 'lib/sm_transcript/metadata.rb', line 84 def boilerplate() JSON end |
#id_from_time ⇒ Object
88 89 90 91 |
# File 'lib/sm_transcript/metadata.rb', line 88 def id_from_time() t = Time.now t.strftime("%y%m%d%H%M") end |
#write_datajs(dest_file) ⇒ Object
While the format this method writes is JSON, it writes a data.js-like file for compatibility with the IIHS demo player. There is also a write_json() method which will write a richer content set.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/sm_transcript/metadata.rb', line 46 def write_datajs(dest_file) # TODO: Do we want to notify user when overwriting existing file? # if File.exists?(dest_file) # p "overwriting existing destination file" # end return if @metadata.empty? id_val = @metadata['name'].chomp + "-#{id_from_time()}" unless @metadata['name'].nil? title_val = @metadata['title'].chomp unless @metadata['title'].nil? speaker_val = @metadata['speaker'].chomp unless @metadata['speaker'].nil? video_val = @metadata['video'].chomp unless @metadata['video'].nil? File.open(dest_file, "w") do |f| # f.puts 'var SMData = {' tmp = JSON.pretty_generate( { 'videos' => [ 'id' => id_val, 'title' => title_val, 'speaker' => speaker_val, 'video' => video_val, 'width' => 320, 'height' => 240, 'duration' => 523, 'preview' => 'preview.png', 'transcripts' => {'en-US' => 'transcript.trn'}, 'audio' => {'en-US' => '../audio/'}, 'defaultLocale' => 'en-US' ], 'locales' => {'en-US' => 'English (US)'} } ) # p tmp f.puts tmp f.flush end end |