Class: Video
- Inherits:
-
Zarchitect
- Object
- Zarchitect
- Video
- Defined in:
- lib/zarchitect/video.rb
Constant Summary
Constants inherited from Zarchitect
Zarchitect::ASSETDIR, Zarchitect::ASSETSDIR, Zarchitect::BUILDIR, Zarchitect::CONFIGDIR, Zarchitect::DEBUGSDIR, Zarchitect::DRAFTDIR, Zarchitect::FILEDIR, Zarchitect::FILESDIR, Zarchitect::HTMLDIR, Zarchitect::LAYOUTDIR, Zarchitect::NODEDIR, Zarchitect::SHARESDIR, Zarchitect::VERSION
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ Video
constructor
A new instance of Video.
Methods inherited from Zarchitect
Constructor Details
#initialize(path) ⇒ Video
Returns a new instance of Video.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# 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 |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
2 3 4 |
# File 'lib/zarchitect/video.rb', line 2 def size @size end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
2 3 4 |
# File 'lib/zarchitect/video.rb', line 2 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
2 3 4 |
# File 'lib/zarchitect/video.rb', line 2 def url @url end |
Class Method Details
.find(k, v) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# 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) ⇒ Boolean
19 20 21 |
# File 'lib/zarchitect/video.rb', line 19 def self.is_valid?(filename) [".mp4",".avi",".webm"].include?(File.extname(filename)) end |