Class: Videoreg::Config
- Inherits:
-
Base
- Object
- Base
- Videoreg::Config
show all
- Defined in:
- lib/videoreg/config.rb
Instance Method Summary
collapse
Methods inherited from Base
logger, logger=, #logger=, #proc_alive?, #tpl, #which
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/videoreg/config.rb', line 5
def initialize
@device = '/dev/video1'
@resolution = '320x240'
@fps = 25
@duration = 10
@filename = '#{time}-#{devname}.DEFAULT.avi'
@command = 'ffmpeg -r #{fps} -s #{resolution} -f video4linux2 -r ntsc -i #{device} -vcodec mjpeg -t #{duration} -an -y #{outfile}'
@storage = '/tmp/#{devname}'
@lockfile = '/tmp/videoreg.#{devname}.DEFAULT.lck'
@store_max = 50
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
set or get inner variable value depending on arguments count
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/videoreg/config.rb', line 39
def method_missing(*args)
if args.length == 2 || args[0] =~ /=$/
mname = args[0].to_s.gsub(/=/, '')
value = args.last
eval("@#{mname}='#{value}'")
elsif args.length == 1
tpl(eval("@#{args[0]}"))
else
super
end
end
|
Instance Method Details
#base_cmd ⇒ Object
33
34
35
|
# File 'lib/videoreg/config.rb', line 33
def base_cmd
command.split(" ").first
end
|
#devname ⇒ Object
51
52
53
|
# File 'lib/videoreg/config.rb', line 51
def devname
device.split('/').last
end
|
#logger ⇒ Object
21
22
23
|
# File 'lib/videoreg/config.rb', line 21
def logger
@logger || self.class.logger
end
|
#outfile ⇒ Object
29
30
31
|
# File 'lib/videoreg/config.rb', line 29
def outfile
"#{storage}/#{filename}"
end
|
#store_max(*args) ⇒ Object
25
26
27
|
# File 'lib/videoreg/config.rb', line 25
def store_max(*args)
(args.length > 0) ? (self.store_max=(args.shift)) : (@store_max.to_i)
end
|
#time ⇒ Object
17
18
19
|
# File 'lib/videoreg/config.rb', line 17
def time
"#{Time.new.strftime("%Y%m%d-%H%M%S%L")}"
end
|