Class: SmTranscript::Word

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_time, end_time, duration, word) ⇒ Word

Returns a new instance of Word.



12
13
14
15
16
17
# File 'lib/sm_transcript/word.rb', line 12

def initialize( start_time, end_time, duration, word )
  @start_time = start_time
  @end_time = end_time
  @duration = duration
  @word = apply_word_rules(word)
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



9
10
11
# File 'lib/sm_transcript/word.rb', line 9

def duration
  @duration
end

#end_timeObject (readonly)

Returns the value of attribute end_time.



8
9
10
# File 'lib/sm_transcript/word.rb', line 8

def end_time
  @end_time
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



7
8
9
# File 'lib/sm_transcript/word.rb', line 7

def start_time
  @start_time
end

#wordObject (readonly)

Returns the value of attribute word.



10
11
12
# File 'lib/sm_transcript/word.rb', line 10

def word
  @word
end

Instance Method Details

#apply_word_rules(word) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sm_transcript/word.rb', line 19

def apply_word_rules(word)
  case word
  when "i"  # (English) "i" appearing as a word is capitalized
    word.upcase
  when "i'm", "i've"  # (English) "i" as personal pronoun is capitalized
    word.capitalize
  when "iranian, american"  # (English) proper nouns are capitalized
    word.capitalize
  else
    word
  end
end