Class: MediatypeDirectory
- Inherits:
-
Object
- Object
- MediatypeDirectory
- Defined in:
- lib/mediatype_directory/mediatype_directory.rb
Overview
MediatypeDirectory.new takes a configuration hash and creates an object with a create_directory() method Calling create_directory() on the MediatypeDirectory object creates a directory, configured according to the configuration hash settings, containing softlinks to all files of the requested file extension(s) in the specified directory tree.
Usage: MediatypeDirectory.new(options_hash).create_directory
Alternative usage: md = MediatypeDirectory.new md.property = value (for all desired property-value pairs) md.create_directory
Example: To create a directory at ‘~/Tech/Docs/PDFs’ with softlinks to all PDF and ODT files under ‘~/Tech’: md = MediatypeDirectory.new md.extensions = [‘.pdf’,‘.odt’] md.mediatype_dirname = ‘~/Tech/Docs/PDFs’ md.directory_tree = ‘~/Tech’ md.create_directory
Defined Under Namespace
Classes: InvalidDirname
Constant Summary collapse
- VIDEO_FILE_EXTENSIONS =
['.3g2','.3gp','.asf','.asx','.avi','.bsf','.dat', '.divx','.dvdmedia','.f4v','.fbr','.flv','.hdmov', '.imovieproj','.m2p','.m4v','.mod','.moi','.mov', '.mp4','.mpeg','.mpg','.mts','.ogm','.ogv','.ogx', '.rm','.rmvb','.scm','.srt','.vob','.vro','.wmv', '.xvid','.yuv']
- AUDIO_FILE_EXTENSIONS =
['.aa','.aa3','.acd','.acm','.aif','.amr','.ape', '.at3','.caf','.dcf','.dss','.emp','.emx','.flac', '.gpx','.iff','.kpl','.m3u','.m3u8','.m4a','.m4b', '.m4p','.mid','.midi','.mod','.mp3','.mpa','.mpga', '.oga','.ogg','.omf','.pcast','.ra','.ram','.snd', '.wav','.wma']
Instance Attribute Summary collapse
-
#directory_tree ⇒ Object
(also: #source, #from)
Returns the value of attribute directory_tree.
-
#extensions ⇒ Object
(also: #what)
Returns the value of attribute extensions.
-
#linktype ⇒ Object
Returns the value of attribute linktype.
-
#mediatype_dirname ⇒ Object
(also: #target, #to)
Returns the value of attribute mediatype_dirname.
-
#mediatype_files ⇒ Object
readonly
Returns the value of attribute mediatype_files.
-
#remove_old_links ⇒ Object
Returns the value of attribute remove_old_links.
-
#test_mode ⇒ Object
Returns the value of attribute test_mode.
Instance Method Summary collapse
- #create_directory ⇒ Object
-
#initialize(config) ⇒ MediatypeDirectory
constructor
A new instance of MediatypeDirectory.
Constructor Details
#initialize(config) ⇒ MediatypeDirectory
Returns a new instance of MediatypeDirectory.
48 49 50 51 52 53 54 55 |
# File 'lib/mediatype_directory/mediatype_directory.rb', line 48 def initialize(config) self.extensions = config[:extensions] || config[:what] self.mediatype_dirname = config[:mediatype_dirname] || config[:target] || config[:to] self.directory_tree = config[:directory_tree] || config[:source] || config[:from] self.linktype = config[:linktype] || 'soft' self.test_mode = config[:test_mode] || false self.remove_old_links = config[:remove_old_links] || false end |
Instance Attribute Details
#directory_tree ⇒ Object Also known as: source, from
Returns the value of attribute directory_tree.
43 44 45 |
# File 'lib/mediatype_directory/mediatype_directory.rb', line 43 def directory_tree @directory_tree end |
#extensions ⇒ Object Also known as: what
Returns the value of attribute extensions.
42 43 44 |
# File 'lib/mediatype_directory/mediatype_directory.rb', line 42 def extensions @extensions end |
#linktype ⇒ Object
Returns the value of attribute linktype.
42 43 44 |
# File 'lib/mediatype_directory/mediatype_directory.rb', line 42 def linktype @linktype end |
#mediatype_dirname ⇒ Object Also known as: target, to
Returns the value of attribute mediatype_dirname.
43 44 45 |
# File 'lib/mediatype_directory/mediatype_directory.rb', line 43 def mediatype_dirname @mediatype_dirname end |
#mediatype_files ⇒ Object (readonly)
Returns the value of attribute mediatype_files.
43 44 45 |
# File 'lib/mediatype_directory/mediatype_directory.rb', line 43 def mediatype_files @mediatype_files end |
#remove_old_links ⇒ Object
Returns the value of attribute remove_old_links.
43 44 45 |
# File 'lib/mediatype_directory/mediatype_directory.rb', line 43 def remove_old_links @remove_old_links end |
#test_mode ⇒ Object
Returns the value of attribute test_mode.
43 44 45 |
# File 'lib/mediatype_directory/mediatype_directory.rb', line 43 def test_mode @test_mode end |
Instance Method Details
#create_directory ⇒ Object
57 58 59 60 61 |
# File 'lib/mediatype_directory/mediatype_directory.rb', line 57 def create_directory check_directories delete_old_links if remove_old_links create_links end |