Class: Walnut::Output::Standard

Inherits:
Object
  • Object
show all
Defined in:
lib/walnut/output/standard.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Standard

Initialize an object

Parameters:



18
19
20
21
# File 'lib/walnut/output/standard.rb', line 18

def initialize(parent)
  @walnut = parent
  @output = $stdout
end

Instance Attribute Details

#outputObject

Note:

#output defaults to $stdout



12
13
14
# File 'lib/walnut/output/standard.rb', line 12

def output
  @output
end

Instance Method Details

#puts(string) ⇒ Object

Write a string with a newline to the output.

See Also:

  • Walnut::Output::Standard.{Walnut{Walnut::Output{Walnut::Output::Standard{Walnut::Output::Standard#write}


37
38
39
# File 'lib/walnut/output/standard.rb', line 37

def puts(string)
  write(string + "\n")
end

#write(string) ⇒ Numeric

Write a string to the output

Parameters:

  • string (#to_s)

    The string that will be written to the output stream.

Returns:

  • (Numeric)

    The number of characters written to the stream.



28
29
30
31
# File 'lib/walnut/output/standard.rb', line 28

def write(string)
  @output.write(string.to_s)
  string.to_s.length
end