Class: Starter::FileFoo

Inherits:
Object
  • Object
show all
Defined in:
lib/starter/builder/file_foo.rb

Class Method Summary collapse

Class Method Details

.call!(file) {|content| ... } ⇒ Object

general file stuff

… reading and writing content

Yields:

  • (content)


9
10
11
12
13
# File 'lib/starter/builder/file_foo.rb', line 9

def call!(file)
  content = read_file(file)
  yield content
  write_file(file, content)
end

.read_file(file) ⇒ Object

… read



16
17
18
# File 'lib/starter/builder/file_foo.rb', line 16

def read_file(file)
  File.read(file)
end

.write_file(file, content) ⇒ Object

… write



21
22
23
# File 'lib/starter/builder/file_foo.rb', line 21

def write_file(file, content)
  File.open(file, 'w') { |f| f.write(content) }
end