Method: Glyph::Utils#file_write

Defined in:
lib/glyph/utils.rb

#file_write(file, contents = "") ⇒ String

Writes a string to a file

Parameters:

  • file (#to_s)

    the file to write

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

    the string to write

Returns:

  • (String)

    the string written to the file

Since:

  • 0.4.0



68
69
70
71
72
73
# File 'lib/glyph/utils.rb', line 68

def file_write(file, contents="")
  File.open(file.to_s, 'w+:utf-8') do |f|
    f.print contents
  end
  contents
end