Class: Ktsh::Meta
- Inherits:
-
Object
- Object
- Ktsh::Meta
- Defined in:
- lib/ktsh.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#resolution ⇒ Object
readonly
Returns the value of attribute resolution.
-
#samples ⇒ Object
readonly
Returns the value of attribute samples.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#tmpdir ⇒ Object
readonly
Returns the value of attribute tmpdir.
-
#video_path ⇒ Object
readonly
Returns the value of attribute video_path.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #info_file ⇒ Object
-
#initialize(video_path, samples, width) ⇒ Meta
constructor
A new instance of Meta.
Constructor Details
#initialize(video_path, samples, width) ⇒ Meta
Returns a new instance of Meta.
14 15 16 17 18 19 20 21 22 |
# File 'lib/ktsh.rb', line 14 def initialize(video_path, samples, width) @video_path = video_path @samples = samples @width = width @tmpdir = FileUtils.mkdir_p(File.join(Dir.tmpdir, 'ktsh', SecureRandom.uuid))[0] probe_video extract_thumbnails end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
12 13 14 |
# File 'lib/ktsh.rb', line 12 def duration @duration end |
#resolution ⇒ Object (readonly)
Returns the value of attribute resolution.
12 13 14 |
# File 'lib/ktsh.rb', line 12 def resolution @resolution end |
#samples ⇒ Object (readonly)
Returns the value of attribute samples.
12 13 14 |
# File 'lib/ktsh.rb', line 12 def samples @samples end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
12 13 14 |
# File 'lib/ktsh.rb', line 12 def size @size end |
#tmpdir ⇒ Object (readonly)
Returns the value of attribute tmpdir.
12 13 14 |
# File 'lib/ktsh.rb', line 12 def tmpdir @tmpdir end |
#video_path ⇒ Object (readonly)
Returns the value of attribute video_path.
12 13 14 |
# File 'lib/ktsh.rb', line 12 def video_path @video_path end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
12 13 14 |
# File 'lib/ktsh.rb', line 12 def width @width end |
Instance Method Details
#info_file ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/ktsh.rb', line 24 def info_file File.join(tmpdir, 'info.txt').tap do |name| File.open(name, 'w') do |f| f.puts "名称: #{File.basename(video_path)}\n体积: #{human_size(size)}\n尺寸: #{resolution}\n时长: #{human_time(duration)}" end end end |