Last active
December 25, 2015 03:09
-
-
Save arches/6907695 to your computer and use it in GitHub Desktop.
table_print for pure ruby objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> my_array = [{server: "localhost", ip: "192.168.0.1"}, {server: "google dns", ip: "8.8.8.8"}] | |
> tp my_array | |
SERVER | IP | |
-----------|------------ | |
localhost | 192.168.0.1 | |
google dns | 8.8.8.8 | |
# or with objects | |
> class ServerInfo | |
> attr_accessor :server, :ip | |
> def initialize(server, ip) | |
> self.server = server | |
> self.ip = ip | |
> end | |
> end | |
> my_array = [ServerInfo.new("localhost", "192.168.0.1"), ServerInfo.new("google dns", "8.8.8.8")] | |
> tp my_array | |
SERVER | IP | |
-----------|------------ | |
localhost | 192.168.0.1 | |
google dns | 8.8.8.8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment