Class: VCSRuby::Tools
- Inherits:
-
Object
- Object
- VCSRuby::Tools
- Defined in:
- lib/tools.rb
Defined Under Namespace
Classes: MagickVersion
Class Method Summary collapse
- .contact_sheet_with_options(video, options) ⇒ Object
- .linux? ⇒ Boolean
- .list_arguments(arguments) ⇒ Object
- .magick_version ⇒ Object
- .print_help(optparse) ⇒ Object
- .to_human_size(size) ⇒ Object
- .windows? ⇒ Boolean
Class Method Details
.contact_sheet_with_options(video, options) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/tools.rb', line 32 def self. video, Configuration.instance.load_profile [:profile] if [:profile] Configuration.instance.capturer = [:capturer] video = VCSRuby::Video.new video unless video.valid? puts "Video '#{video.full_path}' cannot be read by Capturer '#{video.capturer_name}'" return nil end sheet = video.contact_sheet sheet.format = [:format] if [:format] sheet.title = [:title] if [:title] sheet.signature = [:signature] if [:signature] sheet.signature = nil if [:no_signature] if [:rows] || [:columns] || [:interval] sheet.initialize_geometry([:rows], [:columns], [:interval]) end if [:width] && [:height] sheet.aspect_ratio = Rational([:width], [:height]) else sheet.aspect_ratio = [:aspect_ratio] if [:aspect_ratio] end sheet.thumbnail_width = [:width] if [:width] sheet.thumbnail_height = [:height] if [:height] sheet.from = [:from] if [:from] sheet.to = [:to] if [:to] sheet.highlight = [:highlight] if [:highlight] sheet. = [:timestamp] if [:timestamp] != nil sheet.softshadow = [:softshadow] if [:softshadow] != nil sheet.polaroid = [:polaroid] if [:polaroid] != nil return sheet end |
.linux? ⇒ Boolean
12 13 14 |
# File 'lib/tools.rb', line 12 def self.linux? return ((RUBY_PLATFORM =~ /linux/) or (RbConfig::CONFIG['host_os'] =~ /linux/i)) end |
.list_arguments(arguments) ⇒ Object
16 17 18 |
# File 'lib/tools.rb', line 16 def self.list_arguments arguments arguments.map{ |argument| argument.to_s }.join(', ') end |
.magick_version ⇒ Object
26 27 28 29 30 |
# File 'lib/tools.rb', line 26 def self.magick_version output = %x[convert -version] m = output.match(/(\d+)\.(\d+)\.(\d+)(-(\d+))?/) MagickVersion.new(m[1].to_i, m[2].to_i, m[3].to_i) end |
.print_help(optparse) ⇒ Object
20 21 22 23 |
# File 'lib/tools.rb', line 20 def self.print_help optparse puts optparse.summarize exit 0 end |
.to_human_size(size) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/tools.rb', line 72 def self.to_human_size size powers = { 'B' => 1 << 10, 'KiB' => 1 << 20, 'MiB' => 1 << 30, 'GiB' => 1 << 40, 'TiB' => 1 << 50 } powers.each_pair do |prefix, power| if size < power return format('%.2f',size.to_f / (power >> 10)) + ' ' + prefix end end end |
.windows? ⇒ Boolean
8 9 10 |
# File 'lib/tools.rb', line 8 def self.windows? return ((RUBY_PLATFORM =~ /win32/ or RUBY_PLATFORM =~ /mingw32/) or (RbConfig::CONFIG['host_os'] =~ /mswin|windows/i)) end |