Sha256: 8fbb4b9e85281bafa26748822b96593b5a74dc3291d08081cb2281a9a905d7b8

Contents?: true

Size: 606 Bytes

Versions: 3

Compression:

Stored size: 606 Bytes

Contents

class Object
  # Outputs an ANSI colored string with the object representation
  def colored_inspect
    case self
    when Exception
      "\e[41;33m#{self.inspect}\e[0m"
    when Numeric, Symbol, TrueClass, FalseClass, NilClass
      "\e[35m#{self.inspect}\e[0m"
    when Live::Notice
      "\e[42;30m#{self}\e[0m"
    when String
      "\e[32m#{self.inspect}\e[0m"
    when Array
      "[#{ self.collect{ |i| i.colored_inspect}.join(', ') }]"
    when Hash
      "{#{ self.collect{ |i| i.collect{|e| e.colored_inspect}.join(' => ') }.join(', ') }}"
    else
      "\e[36m#{self}\e[0m"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
live-0.1.2 lib/ext/object.rb
live-0.1.1 lib/ext/object.rb
live-0.1.0 lib/ext/object.rb