class Video

Attributes

size[R]
type[R]
url[R]

Public Class Methods

find(k, v) click to toggle source
# File lib/zarchitect/video.rb, line 23
def self.find(k, v)
  GPI.print "Looking for video: #{v}", GPI::CLU.check_option('v')
  ObjectSpace.each_object(Video) do |a|
    str = a.send(k)
    if str == v
      GPI.print "Video found", GPI::CLU.check_option('v')
      @@search = false
      return a
    end
  end
  @@search = false
  nil
end
is_valid?(filename) click to toggle source
# File lib/zarchitect/video.rb, line 19
def self.is_valid?(filename)
  [".mp4",".avi",".webm"].include?(File.extname(filename))
end
new(path) click to toggle source
# File lib/zarchitect/video.rb, line 4
def initialize(path)
  @path = path
  @url = path.clone
  @url[0] = "/"
  @size = File.size(path)
  @type = "video/" << File.extname(path)[1..-1]

  if @size > Zarchitect.conf.video_limit.to_f.mib_to_bytes
    GPI.print "Error: File #{path} too large "\
      "(#{@size.bytes_to_mib.to_f.round(2)}MiB)."\
      " Allowed size: #{Zarchitect.conf.video_limit.to_f.mb_to_mib.round(2)}"
    GPI.quit
  end
end