I am doing a set difference and printing the difference using the awesome_print gem:
ap (a | b ) - (a & b)
This prints out the two items that are different.
Is there a way to highlight or color the difference between the two?
I am doing a set difference and printing the difference using the awesome_print gem:
ap (a | b ) - (a & b)
This prints out the two items that are different.
Is there a way to highlight or color the difference between the two?
Copyright © 2021 Jogjafile Inc.
I don't see how you can do what you want to achieve. As you may know, Awesome Print allows you to specify the colors of different objects (arrays, hashes, strings, etc.). The Awesome Print docs are here.
Suppose you wished to print a set containing the symbol, :cat, and the string, "dog", with the set "blue", :cat "purplish" and "dog" greenish. You could do that as follows (it appears the color for arrays is applied to sets, which makes sense):
and the set would be displayed like this:
When the two elements are of the same class, however, it appears the best you can do is print them separately, by invoking
apfor each:which displays:
If you wanted to assign a particular color to each element of
aandb, you may want to do something like this:where
color_mapis a method you would write.You may need to first convert the
JSONobject to a string (if it is not already a string--I'm not familiar withJSON).