class StatusFile
status = StatusFile.new
'/tmp/status' status.send “Initialized on: #{Time.now}” status.send “Working… #{(1..100).to_a.shuffle.first}%” status.update
Public Class Methods
new(file_path)
click to toggle source
# File lib/status_file.rb, line 8 def initialize(file_path) @file_path = file_path @contents = [] end
Public Instance Methods
read()
click to toggle source
# File lib/status_file.rb, line 25 def read File.read(@file_path) end
send(data)
click to toggle source
# File lib/status_file.rb, line 13 def send data @contents << data end
update()
click to toggle source
# File lib/status_file.rb, line 17 def update File.open(@file_path, 'w+') do |file| @contents.each do |line| file.puts line end end end