Module: IO::Writable

Defined in:
opal/opal/corelib/io.rb

Instance Method Summary collapse

Instance Method Details

#<<(string) ⇒ Object



28
29
30
31
# File 'opal/opal/corelib/io.rb', line 28

def <<(string)
  write(string)
  self
end


33
34
35
36
37
38
39
40
41
# File 'opal/opal/corelib/io.rb', line 33

def print(*args)
  %x{
    for (var i = 0, ii = args.length; i < ii; i++) {
      args[i] = #{String(`args[i]`)}
    }
    self.$write(args.join(#{$,}));
  }
  nil
end

#puts(*args) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'opal/opal/corelib/io.rb', line 43

def puts(*args)
  %x{
    for (var i = 0, ii = args.length; i < ii; i++) {
      args[i] = #{String(`args[i]`).chomp}
    }
    self.$write(args.concat([nil]).join(#{$/}));
  }
  nil
end