Class: Rant::MultiFileList

Inherits:
Object show all
Defined in:
lib/rant/rantsys.rb

Overview

class RacFileList

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rac) ⇒ MultiFileList

Returns a new instance of MultiFileList.



97
98
99
100
101
# File 'lib/rant/rantsys.rb', line 97

def initialize(rac)
    @rac = rac
    @cur_list = RacFileList.new(@rac)
    @lists = [@cur_list]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/rant/rantsys.rb', line 116

def method_missing(sym, *args, &block)
    if @cur_list && @cur_list.respond_to?(sym)
	if @cur_list.subdir == @rac.current_subdir
	    @cur_list.send(sym, *args, &block)
	else
	    add(RacFileList.new(@rac))
	    @cur_list.send(sym, *args, &block)
	end
    else
	super
    end
end

Instance Attribute Details

#cur_listObject (readonly)

Returns the value of attribute cur_list.



95
96
97
# File 'lib/rant/rantsys.rb', line 95

def cur_list
  @cur_list
end

Instance Method Details

#add(filelist) ⇒ Object



109
110
111
112
113
114
# File 'lib/rant/rantsys.rb', line 109

def add(filelist)
    # TODO: validate filelist
    @cur_list = filelist
    @lists << filelist
    self
end

#each_entry(&block) ⇒ Object



103
104
105
106
107
# File 'lib/rant/rantsys.rb', line 103

def each_entry(&block)
    @lists.each { |list|
	list.each_cd(&block)
    }
end