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.



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

def initialize client, *rest
  @client = client
end

Class Method Details

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



41
42
43
44
45
46
# File 'lib/neovim/output.rb', line 41

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

Instance Method Details

#<<(arg) ⇒ Object



51
52
53
54
# File 'lib/neovim/output.rb', line 51

def << arg
  write arg.to_s
  self
end

#flushObject



78
79
# File 'lib/neovim/output.rb', line 78

def flush
end


55
56
57
58
# File 'lib/neovim/output.rb', line 55

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

#puts(*args) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/neovim/output.rb', line 59

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