Module: FileStrModule

Included in:
FileStr
Defined in:
lib/filestr.rb

Overview

FileStr class related module which maps missing methods to FileStr defined methods.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object

Call FileStr supported methods (if available).



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/filestr.rb', line 14

def method_missing( m, *args, &block )

    klass = FileStr.support[ m ]

    if klass
        # Generate the actual class method name.
        cm = m.to_s[2..-1].to_sym
        klass.send( cm, self, *args, &block )
    else
        raise NoMethodError
    end
end

Instance Method Details

#s_chmod(mode_int) ⇒ Object

Chmod with mode_int.

Parameters:

  • mode_int (Integer)

    New file mode.



34
35
36
# File 'lib/filestr.rb', line 34

def s_chmod( mode_int )
    File.chmod( mode_int, self )
end

#s_chown(owner_int, group_int) ⇒ Object

Chown with owner_int, group_int.

Parameters:

  • owner_int (Integer)

    New file owner.

  • group_int (Integer)

    New file group.



42
43
44
# File 'lib/filestr.rb', line 42

def s_chown( owner_int, group_int )
    File.chown( owner_int, group_int, self )
end

#s_fnmatch(pattern, *flags) ⇒ Object

Fnmatch to pattern with flags.

Parameters:

  • pattern (String)

    Glob patttern for matching.

  • flags (Constant)

    Flags for matching.



50
51
52
# File 'lib/filestr.rb', line 50

def s_fnmatch( pattern, *flags )
    File.fnmatch( pattern, self, *flags )
end

#s_glob(pattern = "", *args, &block) ⇒ Object

Glob with self as base string.

Parameters:

  • pattern (String) (defaults to: "")

    Suffix of glob pattern (concat to self).



61
62
63
# File 'lib/filestr.rb', line 61

def s_glob( pattern = "", *args, &block )
    Dir.glob( self + pattern, *args, &block )
end