Module: Mumukit::WithTempfile
- Included in:
- Templates::FileHook
- Defined in:
- lib/mumukit/with_tempfile.rb
Instance Method Summary collapse
- #create_tempfile ⇒ Object
- #tempfile_extension ⇒ Object
- #with_tempfile {|file| ... } ⇒ Object
- #write_tempfile!(content) ⇒ Object
Instance Method Details
#create_tempfile ⇒ Object
5 6 7 |
# File 'lib/mumukit/with_tempfile.rb', line 5 def create_tempfile Tempfile.new(['mumuki.compile', tempfile_extension]) end |
#tempfile_extension ⇒ Object
9 10 11 |
# File 'lib/mumukit/with_tempfile.rb', line 9 def tempfile_extension '' end |
#with_tempfile {|file| ... } ⇒ Object
19 20 21 22 23 24 |
# File 'lib/mumukit/with_tempfile.rb', line 19 def with_tempfile file = create_tempfile yield file file.close file end |
#write_tempfile!(content) ⇒ Object
13 14 15 16 17 |
# File 'lib/mumukit/with_tempfile.rb', line 13 def write_tempfile!(content) with_tempfile do |file| file.write(content) end end |