Class: Fudge::Formatters::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/fudge/formatters/simple.rb

Overview

Simple coloured STDOUT/STDERR formatting

Defined Under Namespace

Classes: Writer

Constant Summary collapse

CODE =

ASCII Color Codes

{
  :off => 0,
  :bright => 1,
  :red => 31,
  :green => 32,
  :yellow => 33,
  :cyan => 36
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdout = $stdout) ⇒ Simple

Returns a new instance of Simple.



46
47
48
# File 'lib/fudge/formatters/simple.rb', line 46

def initialize(stdout=$stdout)
  @stdout = stdout
end

Instance Attribute Details

#stdoutObject (readonly)

Returns the value of attribute stdout.



44
45
46
# File 'lib/fudge/formatters/simple.rb', line 44

def stdout
  @stdout
end

Instance Method Details

#error(message) ⇒ Object

Report Error Message



51
52
53
# File 'lib/fudge/formatters/simple.rb', line 51

def error(message)
  ascii :red, message
end

#info(message) ⇒ Object

Report Information Message



61
62
63
# File 'lib/fudge/formatters/simple.rb', line 61

def info(message)
  ascii :cyan, message
end

#normal(message) ⇒ Object

Normal information



71
72
73
# File 'lib/fudge/formatters/simple.rb', line 71

def normal(message)
  message
end

#notice(message) ⇒ Object

Report Notice Message



66
67
68
# File 'lib/fudge/formatters/simple.rb', line 66

def notice(message)
  ascii :yellow, message
end

#putc(c) ⇒ Object

Output a character



88
89
90
# File 'lib/fudge/formatters/simple.rb', line 88

def putc(c)
  stdout.putc(c)
end

#puts(message) ⇒ Object

Directly output



76
77
78
# File 'lib/fudge/formatters/simple.rb', line 76

def puts(message)
  stdout.puts message
end

#success(message) ⇒ Object

Report Success Message



56
57
58
# File 'lib/fudge/formatters/simple.rb', line 56

def success(message)
  ascii :bright, :green, message
end

#write {|w| ... } ⇒ Object

Yields a writer which can chain message types to output

Yields:

  • (w)


81
82
83
84
85
# File 'lib/fudge/formatters/simple.rb', line 81

def write
  w = Writer.new(self)
  yield w
  w.write(stdout)
end