class RShade::Formatter::File

Constants

FILE_NAME

Attributes

event_store[R]
formatter[R]

Public Class Methods

new(event_store, args={}) click to toggle source
# File lib/rshade/formatter/file.rb, line 7
def initialize(event_store, args={})
  @event_store = event_store
  @formatter = args.fetch(:format, Json)
end

Public Instance Methods

call() click to toggle source
# File lib/rshade/formatter/file.rb, line 12
def call
  data = formatter.call(event_store)
  if formatter == Json
    write_to_file(JSON.pretty_generate(data))
  else
    write_to_file(data.to_s)
  end
end
write_to_file(data) click to toggle source
# File lib/rshade/formatter/file.rb, line 21
def write_to_file(data)
  ::File.open(::File.join(RShade.config.store_dir, FILE_NAME), "w+") do |f|
    f.write data
  end
end