Class: SmTranscript::MetadataReader
- Inherits:
-
Object
- Object
- SmTranscript::MetadataReader
- Defined in:
- lib/sm_transcript/metadata_reader.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#words ⇒ Object
readonly
Returns the value of attribute words.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(src_file) ⇒ MetadataReader
constructor
A new instance of MetadataReader.
- #parse_metadata(src_file) ⇒ Object
- #parse_words(src_file) ⇒ Object
Constructor Details
#initialize(src_file) ⇒ MetadataReader
Returns a new instance of MetadataReader.
21 22 23 24 25 26 |
# File 'lib/sm_transcript/metadata_reader.rb', line 21 def initialize(src_file) @metadata = {} @words = [] (src_file) # parse_words(src_file) end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
13 14 15 |
# File 'lib/sm_transcript/metadata_reader.rb', line 13 def @metadata end |
#words ⇒ Object (readonly)
Returns the value of attribute words.
14 15 16 |
# File 'lib/sm_transcript/metadata_reader.rb', line 14 def words @words end |
Class Method Details
.from_file(file_name) ⇒ Object
16 17 18 19 |
# File 'lib/sm_transcript/metadata_reader.rb', line 16 def self.from_file(file_name) # p File.expand_path(file_name) new(File.open(file_name)) end |
Instance Method Details
#parse_metadata(src_file) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sm_transcript/metadata_reader.rb', line 28 def (src_file) # don't process PLACEHOLDER.txt reg = Regexp.new('.*PLACEHOLDER.*') src_file.each do |ln| # break if src_file.lineno > 6 # we're only interested in the 1st 6 lines case src_file.lineno when 1 return if reg.match(ln) @metadata['name'] = ln when 2 @metadata['email'] = ln when 3 @metadata['org'] = ln when 4 @metadata['title'] = ln when 5 @metadata['speaker'] = ln when 6 @metadata['video'] = ln else break end end end |
#parse_words(src_file) ⇒ Object
54 55 56 |
# File 'lib/sm_transcript/metadata_reader.rb', line 54 def parse_words(src_file) # there are currently no timed text in metadata files end |