ModraUp Ruby API Documentation Ruby API Reference

Class: ModraUp::Console

Inherits:
Object
  • Object
show all

Overview

Hosted in the Ruby Console. SketchUp redirects $stdout / $stderr to the single instance of SKETCHUP_CONSOLE, so plugins' p / puts / warn will write to the console window rather than the process terminal. Objects conform to the IO duck type by providing write / flush / tty?, otherwise MRI 3.2 will raise a NoMethodError when writing warnings. Writes from non-main threads will be dropped (consistent with SketchUp 2014+).

Examples:

p SKETCHUP_CONSOLE
SKETCHUP_CONSOLE.show

Instance Method Summary # collapse

Instance Method Details

console.write(string) ⇒ Integer

Write the string to the console without a newline. Returns the number of bytes written. Kernel#p / Kernel#puts Call this method by invoking $stdout.

Parameters:

  • string (String)

Returns:

  • (Integer)

Examples:

SKETCHUP_CONSOLE.write("hello\n")

console << string ⇒ console

Like #write, returns self so that $stdout << "x" can be chained.

Parameters:

  • string (String)

Returns:

  • (ModraUp::Console)

Examples:

SKETCHUP_CONSOLE << "hello\n"

console.flush ⇒ console

The console has no underlying buffer and returns self with an empty operation. MRI redirects $stderr to this object, causing warnings and RubyVM::InstructionSequence.compile to call flush; without this method, the plugin require 'forwardable' will raise a NoMethodError.

Returns:

  • (ModraUp::Console)

Examples:

SKETCHUP_CONSOLE.flush

console.tty? ⇒ false

Not a terminal. Use $stdout.tty?. Go here.

Returns:

  • (false)

Examples:

SKETCHUP_CONSOLE.tty?  #=> false

console.isatty ⇒ false

Alias for #tty?.

Returns:

  • (false)

Examples:

SKETCHUP_CONSOLE.isatty  #=> false

console.closed? ⇒ false

The console cannot be closed and remains false.

Returns:

  • (false)

Examples:

SKETCHUP_CONSOLE.closed?  #=> false

console.close ⇒ nil

Does nothing. The standard library sometimes calls close on $stdout.

Returns:

  • (nil)

Examples:

SKETCHUP_CONSOLE.close

console.close_write ⇒ nil

Does nothing.

Returns:

  • (nil)

Examples:

SKETCHUP_CONSOLE.close_write

console.sync ⇒ true

Unbuffered, always true.

Returns:

  • (true)

Examples:

SKETCHUP_CONSOLE.sync  #=> true

console.sync = value ⇒ value

Ignore the assignment and still treat it as unbuffered.

Parameters:

  • value (Object)

Returns:

  • (Object) Return the original value value

Examples:

SKETCHUP_CONSOLE.sync = true

console.show ⇒ true

Open the Ruby Console window.

Returns:

  • (true)

Examples:

SKETCHUP_CONSOLE.show

console.hide ⇒ true

Hide the Ruby Console window.

Returns:

  • (true)

Examples:

SKETCHUP_CONSOLE.hide

console.clear ⇒ true

Clear the console output.

Returns:

  • (true)

Examples:

SKETCHUP_CONSOLE.clear

console.visible? ⇒ Boolean

Whether the Console window is displayed.

Returns:

  • (Boolean)

Examples:

SKETCHUP_CONSOLE.visible?