Class: Sinatra::Helpers::Stream

Inherits:
Object
  • Object
show all
Defined in:
app/openbel/api/helpers/translators.rb

Overview

Open Stream and add the puts, write, and flush methods. This is necessary because the RDF.rb writers will call these methods on the IO (in this case Stream).

Instance Method Summary collapse

Instance Method Details

#flushObject

flush is a no-op; flushing is handled by sinatra/rack server



28
# File 'app/openbel/api/helpers/translators.rb', line 28

def flush; end

#puts(*args) ⇒ Object

Write each string in +args*, new-line delimited, to the stream.



16
17
18
19
20
# File 'app/openbel/api/helpers/translators.rb', line 16

def puts(*args)
  self << (
    args.map { |string| "#{string.encode(Encoding::UTF_8)}\n" }.join
  )
end

#write(string) ⇒ Object

Write the string to the stream.



23
24
25
# File 'app/openbel/api/helpers/translators.rb', line 23

def write(string)
  self << string.encode(Encoding::UTF_8)
end