Sha256: 6378619601bde74e611b1174b38eda87c0a71b2dc6d8036cc7b2a391f8304863

Contents?: true

Size: 1.69 KB

Versions: 3

Compression:

Stored size: 1.69 KB

Contents

#
# Dependencies
#

module VCSRuby
  class Tools
    def self.windows?
      false
    end

    def self.verbose= verbose
      @verbose = verbose
      @quiet = false if @verbose
    end

    def self.verbose?
      @verbose
    end

    def self.quiet= quiet
      @quiet = quiet
      @verbose = false if @quiet
    end

    def self.quiet?
      @quiet
    end

    def self.list_arguments arguments
      arguments.map{ |argument| argument.to_s }.join(', ')
    end

    def self.print_help optparse
      puts optparse.summarize
      exit 0
    end

    def self.contact_sheet_with_options video, options
      sheet = VCSRuby::ContactSheet.new video, options[:capturer]
      sheet.format = options[:format] if options[:format]
      sheet.title = options[:title] if options[:title]
      sheet.signature = options[:signature] if options[:signature]
      sheet.signature = nil if options[:no_signature]

      if options[:rows] || options[:columns] || options[:interval]
        sheet.initialize_geometry(options[:rows], options[:columns], options[:interval])
      end

      sheet.thumbnail_width = options[:width] if options[:width]
      sheet.thumbnail_height = options[:height] if options[:height]
      sheet.from = options[:from] if options[:from]
      sheet.to = options[:to] if options[:to]
      sheet.highlight = options[:highlight] if options[:highlight]

      return sheet
    end

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vcs_ruby-0.8.2 lib/tools.rb
vcs_ruby-0.8.1 lib/tools.rb
vcs_ruby-0.8.0 lib/tools.rb