Class: Swig::Stream
- Inherits:
-
Object
- Object
- Swig::Stream
- Defined in:
- lib/swig/stream.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #clean(pattern = //) ⇒ Object
-
#initialize ⇒ Stream
constructor
A new instance of Stream.
- #read(path_or_paths) ⇒ Object
- #then(klass, options = {}) ⇒ Object
- #write(path) ⇒ Object
Constructor Details
#initialize ⇒ Stream
Returns a new instance of Stream.
8 9 10 |
# File 'lib/swig/stream.rb', line 8 def initialize @files = [] end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/swig/stream.rb', line 6 def files @files end |
Instance Method Details
#clean(pattern = //) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/swig/stream.rb', line 32 def clean(pattern = //) @files = @files.reject do |file| pattern =~ file.basename end self end |
#read(path_or_paths) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/swig/stream.rb', line 12 def read(path_or_paths) Dir.glob(path_or_paths).each do |path| basename = File.basename(path) content = File.read(path) @files << Swig::FileInStream.new(basename, content) end self end |
#then(klass, options = {}) ⇒ Object
40 41 42 43 44 |
# File 'lib/swig/stream.rb', line 40 def then(klass, = {}) @files = klass.new().eval(@files) self end |
#write(path) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/swig/stream.rb', line 22 def write(path) FileUtils.mkdir_p(path) @files.each do |file| File.write(File.join(path, file.basename), file.read) end self end |