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.



23
24
25
# File 'lib/vidibus/recording/part.rb', line 23

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

#has_data?Boolean

Returns:

  • (Boolean)


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

def has_data?
  size.to_i >= SIZE_THRESHOLD
end

#postprocessObject



57
58
59
60
61
62
# File 'lib/vidibus/recording/part.rb', line 57

def postprocess
  process_yml_file
  track_progress
  self.stopped_at = Time.now
  # save!
end

#resetObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/vidibus/recording/part.rb', line 40

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

#startObject



64
65
66
67
# File 'lib/vidibus/recording/part.rb', line 64

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

#stopped?Boolean

Returns:

  • (Boolean)


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

def stopped?
  !!stopped_at
end

#track_progressObject



52
53
54
55
# File 'lib/vidibus/recording/part.rb', line 52

def track_progress
  set_size
  set_duration
end

#yml_fileObject

Returns the YAML file path of this part.



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

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