Class: ColorDebugMessages::ColorDebugMsg

Inherits:
Object
  • Object
show all
Includes:
Term::ANSIColor
Defined in:
lib/color_debug_messages.rb

Overview

:nodoc:all

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, prefix = nil, mark = nil, color = nil) ⇒ ColorDebugMsg

Returns a new instance of ColorDebugMsg.



76
77
78
79
80
81
# File 'lib/color_debug_messages.rb', line 76

def initialize(msg, prefix=nil, mark=nil, color=nil)
  @color  = color
  @mark   = mark
  @prefix = prefix
  @msg    = msg
end

Instance Attribute Details

#calling_method_nameObject (readonly)

Returns the value of attribute calling_method_name.



74
75
76
# File 'lib/color_debug_messages.rb', line 74

def calling_method_name
  @calling_method_name
end

#colorObject (readonly)

Returns the value of attribute color.



74
75
76
# File 'lib/color_debug_messages.rb', line 74

def color
  @color
end

#markObject (readonly)

Returns the value of attribute mark.



74
75
76
# File 'lib/color_debug_messages.rb', line 74

def mark
  @mark
end

#msgObject (readonly)

Returns the value of attribute msg.



74
75
76
# File 'lib/color_debug_messages.rb', line 74

def msg
  @msg
end

Instance Method Details

#to_sObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/color_debug_messages.rb', line 83

def to_s
  str = ''
  if @prefix
    if @color
      str += send @color, bold('[')
      str += send @color, @prefix
      str += send @color, bold('] ')
    else
      str += "[#{@prefix}] "
    end
  end

  if @mark
    mark_str = @mark + @mark + '> '
    if @color
      str += send @color, bold(mark_str)
    else
      str += mark_str
    end
  end

  str += reset if @color
  str += @msg
end