Class: Neovim::Write

Inherits:
Object show all
Defined in:
lib/neovim/output.rb

Direct Known Subclasses

WriteErr, WriteStd

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, *rest) ⇒ Write

Returns a new instance of Write.



17
18
19
# File 'lib/neovim/output.rb', line 17

def initialize client, *rest
  @client = client
end

Class Method Details

.open(*args, **kwargs) ⇒ Object



10
11
12
13
14
15
# File 'lib/neovim/output.rb', line 10

def open *args, **kwargs
  i = new *args, **kwargs
  yield i
ensure
  i.finish
end

Instance Method Details

#<<(arg) ⇒ Object



20
21
22
23
# File 'lib/neovim/output.rb', line 20

def << arg
  write arg.to_s
  self
end

#flushObject



47
48
# File 'lib/neovim/output.rb', line 47

def flush
end


24
25
26
27
# File 'lib/neovim/output.rb', line 24

def print *args
  args.each { |a| write a.to_s }
  nil
end

#puts(*args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/neovim/output.rb', line 28

def puts *args
  if args.empty? then
    write $/
  else
    args.each { |a|
      case a
      when Array then
        a.each { |e|
          puts e
        }
      else
        a = a.to_s
        write a
        write $/ unless a.end_with? $/
      end
    }
  end
  nil
end