Class: Merb::Global::DateProviders::Fork

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/merb_global/date_providers/fork.rb

Instance Method Summary collapse

Instance Method Details

#localize(lang, date, format) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/merb_global/date_providers/fork.rb', line 9

def localize(lang, date, format)
  pipe_rd, pipe_wr = IO.pipe
  pid = fork do
    pipe_rd.close
    setlocale(lang.to_s)
    pipe_wr.write(date.strftime(format))
    pipe_wr.flush
  end
  pipe_wr.close
  Process.wait(pid)
  pipe_rd.read
end