Class: GuessMethod::GuessMethodOutputter

Inherits:
Object
  • Object
show all
Defined in:
lib/guessmethod.rb

Overview

GuessMethodOutputter uses a little Formatter class for colorization

Defined Under Namespace

Classes: Formatter

Class Method Summary collapse

Class Method Details

.ambigious_const(sym, possibilities, obj) ⇒ Object

:nodoc:



173
174
175
176
177
178
179
180
181
# File 'lib/guessmethod.rb', line 173

def self.ambigious_const(sym, possibilities, obj) #:nodoc:
  Formatter.color('ambigious constant:', :red) <<
  ' ' <<
  Formatter.color(sym, :green) <<
  ' possible matches ' <<
  possibilities.map {|m| Formatter.color(m, :cyan)}.join(', ') <<
  ' for ' <<
  Formatter.color(obj, :green, :bold)
end

.ambiguous_method(meth, possibilities, obj) ⇒ Object

:nodoc:



146
147
148
149
150
151
152
153
154
# File 'lib/guessmethod.rb', line 146

def self.ambiguous_method(meth, possibilities, obj) #:nodoc:
  Formatter.color('ambigious method:', :red) <<
  ' ' <<
  Formatter.color(meth, :green) <<
  ' possible matches ' <<
  possibilities.map {|m| Formatter.color(m, :cyan)}.join(', ') <<
  ' for ' <<
  GuessMethodOutputter.object(obj)
end

.no_const_in_threshold(sym, obj) ⇒ Object

:nodoc:



183
184
185
186
187
188
# File 'lib/guessmethod.rb', line 183

def self.no_const_in_threshold(sym, obj) #:nodoc:
  Formatter.color('no constant in threshold: ', :red) <<
  Formatter.color(sym, :green) <<
  ' for ' <<
  Formatter.color(obj, :green, :bold)
end

.no_method_in_threshold(meth, obj) ⇒ Object

:nodoc:



156
157
158
159
160
161
# File 'lib/guessmethod.rb', line 156

def self.no_method_in_threshold(meth, obj)  #:nodoc:
  Formatter.color('no method in threshold: ', :red) <<
  Formatter.color(meth, :green) <<
  ' for ' <<
  GuessMethodOutputter.object(obj)
end

.object(obj) ⇒ Object

:nodoc:



137
138
139
140
141
142
143
144
# File 'lib/guessmethod.rb', line 137

def self.object(obj)  #:nodoc:
  inspected = obj.inspect
  if obj.inspect.length > GuessMethodOptions[:max_inspect_length]
    Formatter.color("#<#{obj.class}:0x#{(obj.object_id*2).to_s(16)}>", :green)
  else
    Formatter.color(obj.inspect, :green, :bold) << ':' << Formatter.color(obj.class, :green)
  end
end

.replacing_const(sym, call_const, obj) ⇒ Object

:nodoc:



190
191
192
193
194
195
196
197
198
# File 'lib/guessmethod.rb', line 190

def self.replacing_const(sym, call_const, obj) #:nodoc:
  Formatter.color('attention:', :red) <<
  ' replacing non-existant constant ' <<
  Formatter.color(sym, :cyan) <<
  ' with ' <<
  Formatter.color(call_const, :cyan) <<
  ' for ' <<
  Formatter.color(obj, :green, :bold)
end

.replacing_method(meth, call_method, obj) ⇒ Object

:nodoc:



163
164
165
166
167
168
169
170
171
# File 'lib/guessmethod.rb', line 163

def self.replacing_method(meth, call_method, obj) #:nodoc:
  Formatter.color('attention:', :red) <<
  ' sending ' <<
  Formatter.color(call_method, :cyan) <<
  ' instead of ' <<
  Formatter.color(meth, :cyan) <<
  ' to ' <<
  GuessMethodOutputter.object(obj)
end