Class: SmTranscript::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/sm_transcript/metadata.rb

Instance Method Summary collapse

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"


40
41
42
# File 'lib/sm_transcript/metadata.rb', line 40

def initialize()
   = 
end

Instance Method Details

#boilerplateObject

write_datajs()



86
87
88
# File 'lib/sm_transcript/metadata.rb', line 86

def boilerplate()
  JSON
end

#id_from_timeObject



90
91
92
93
# File 'lib/sm_transcript/metadata.rb', line 90

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.



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
83
84
# File 'lib/sm_transcript/metadata.rb', line 48

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 .empty?
  
  id_val = ['name'].chomp + "-#{id_from_time()}" unless ['name'].nil?
  title_val = ['title'].chomp unless ['title'].nil?
  speaker_val = ['speaker'].chomp unless ['speaker'].nil?
  video_val = ['video'].chomp unless ['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