Class: Vidibus::Recording::Part

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps, Helpers
Defined in:
lib/vidibus/recording/part.rb

Constant Summary collapse

SIZE_THRESHOLD =
2000

Instance Method Summary collapse

Methods included from Helpers

#fix_value_classes!

Instance Method Details

#data_fileObject

Returns the file path of this part.



27
28
29
# File 'lib/vidibus/recording/part.rb', line 27

def data_file
  @data_file ||= "#{basename}.f4v"
end

#has_data?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/vidibus/recording/part.rb', line 36

def has_data?
  size.to_i >= SIZE_THRESHOLD
end

#postprocessObject



61
62
63
64
65
# File 'lib/vidibus/recording/part.rb', line 61

def postprocess
  process_yml_file
  track_progress
  self.stopped_at = Time.now
end

#resetObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/vidibus/recording/part.rb', line 44

def reset
  remove_files
  blanks = {}
  [
    :info,
    :size,
    :duration,
    :started_at
  ].map {|a| blanks[a] = nil }
  update_attributes(blanks)
end

#startObject



67
68
69
70
# File 'lib/vidibus/recording/part.rb', line 67

def start
  self.started_at = Time.now
  self.stopped_at = nil
end

#stopped?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/vidibus/recording/part.rb', line 40

def stopped?
  !!stopped_at
end

#track_progressObject



56
57
58
59
# File 'lib/vidibus/recording/part.rb', line 56

def track_progress
  set_size
  set_duration
end

#yml_fileObject

Returns the YAML file path of this part.



32
33
34
# File 'lib/vidibus/recording/part.rb', line 32

def yml_file
  @yml_file ||= "#{basename}.yml"
end