class Icomoon::Cli::Writer

Public Class Methods

write(path) { |file| ... } click to toggle source
# File lib/icomoon/cli/writer.rb, line 5
def write(path)
  return unless block_given?

  path = File.expand_path(path)

  File.new(path, 'w+').tap do |file|
    yield file
    file.close
  end

  path
end
write_json(path, json = {}) click to toggle source
# File lib/icomoon/cli/writer.rb, line 18
def write_json(path, json = {})
  write(path) do |file|
    file.puts(JSON.pretty_generate(json))
  end
end