Class: Pathname

Inherits:
Object
  • Object
show all
Defined in:
lib/videos/core_ext/pathname.rb

Constant Summary collapse

VIDEO_EXTS =
%w(.mp4 .mkv .flv .avi .m4v .mov .wmv .mpg .webm)

Instance Method Summary collapse

Instance Method Details

#descendant_filesObject



2
3
4
5
6
7
8
# File 'lib/videos/core_ext/pathname.rb', line 2

def descendant_files
  out = children.select { |p| p.video? && !p.hidden? }
  children.select { |p| p.directory? && !p.hidden? }.each do |p|
    out += p.descendant_files
  end
  out
end

#hidden?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/videos/core_ext/pathname.rb', line 16

def hidden?
  basename.to_s[0..0] == "."
end

#video?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/videos/core_ext/pathname.rb', line 12

def video?
  file? && extname && VIDEO_EXTS.any? { |t| extname.downcase.start_with?(t) }
end