org.scalactic.PrettyMethods.scala Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2001-2013 Artima, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.scalactic
/**
* Provides an implicit conversion that enables pretty
to be invoked on any
* object, to transform that object into a String
representation.
*/
trait PrettyMethods {
/**
* Implicit class that adds a pretty
method to any object.
*
*
* The constructor of this class, besides taking an object o
to prettify,
* also takes an implicit Prettifier
that the pretty
method will use to prettify the
* object.
*
*
* @param o the object to prettify
* @param prettifier an implicit Prettifier
that will be used
* to prettify the passed object o
*/
implicit class Prettyizer(o: Any)(implicit prettifier: Prettifier) {
/**
* Returns a pretty String
representation of the object o
*/
def pretty: String = prettifier(o)
}
}
/**
* Companion object for trait PrettyMethods
enabling its members to be imported as an
* alternative to mixing them in.
*/
object PrettyMethods extends PrettyMethods
© 2015 - 2024 Weber Informatics LLC | Privacy Policy