Module: Wpxf::OutputEmitters

Included in:
Module
Defined in:
lib/wpxf/core/output_emitters.rb

Overview

Provides methods for emitting events that should output information to the user interface of the calling application.

Instance Method Summary collapse

Instance Method Details

#emit_error(message, verbose = false) ⇒ Object

Emit an error event.

Parameters:

  • message (String)

    the message to output.

  • verbose (Boolean) (defaults to: false)

    the verbose level flag.



46
47
48
49
50
51
52
53
# File 'lib/wpxf/core/output_emitters.rb', line 46

def emit_error(message, verbose = false)
  event_emitter.emit(
    event: :output,
    verbose: verbose,
    type: :error,
    msg: message
  )
end

#emit_info(message, verbose = false) ⇒ Object

Emit a general info event.

Parameters:

  • message (String)

    the message to output.

  • verbose (Boolean) (defaults to: false)

    the verbose level flag.



22
23
24
25
26
27
28
29
# File 'lib/wpxf/core/output_emitters.rb', line 22

def emit_info(message, verbose = false)
  event_emitter.emit(
    event: :output,
    verbose: verbose,
    type: :info,
    msg: message
  )
end

#emit_success(message, verbose = false) ⇒ Object

Emit a successful operation event.

Parameters:

  • message (String)

    the message to output.

  • verbose (Boolean) (defaults to: false)

    the verbose level flag.



10
11
12
13
14
15
16
17
# File 'lib/wpxf/core/output_emitters.rb', line 10

def emit_success(message, verbose = false)
  event_emitter.emit(
    event: :output,
    verbose: verbose,
    type: :success,
    msg: message
  )
end

#emit_table(rows, verbose = false) ⇒ Object

Emit an event containing tabular data.

Parameters:

  • rows (Array)

    an array of hashes containing the row data.

  • verbose (Boolean) (defaults to: false)

    the verbose level flag.



58
59
60
61
62
63
64
65
# File 'lib/wpxf/core/output_emitters.rb', line 58

def emit_table(rows, verbose = false)
  event_emitter.emit(
    event: :output,
    verbose: verbose,
    type: :table,
    rows: rows
  )
end

#emit_warning(message, verbose = false) ⇒ Object

Emit a warning event.

Parameters:

  • message (String)

    the message to output.

  • verbose (Boolean) (defaults to: false)

    the verbose level flag.



34
35
36
37
38
39
40
41
# File 'lib/wpxf/core/output_emitters.rb', line 34

def emit_warning(message, verbose = false)
  event_emitter.emit(
    event: :output,
    verbose: verbose,
    type: :warning,
    msg: message
  )
end