From 2e2528529772559a1ee2888a9c529374ffa46a4e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 10 Aug 2012 00:38:11 -0700 Subject: [PATCH] Add nice inspect results for Environment and Machine --- lib/vagrant/environment.rb | 8 ++++++++ lib/vagrant/machine.rb | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 532d1d030..7be9e476e 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -104,6 +104,14 @@ module Vagrant activate_plugins end + # Return a human-friendly string for pretty printed or inspected + # instances. + # + # @return [String] + def inspect + "#<#{self.class}: #{@cwd}>" + end + #--------------------------------------------------------------- # Helpers #--------------------------------------------------------------- diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 70498bf56..2f3173901 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -151,6 +151,14 @@ module Vagrant @id = value end + # This returns a clean inspect value so that printing the value via + # a pretty print (`p`) results in a readable value. + # + # @return [String] + def inspect + "#<#{self.class}: #{@name} (#{@provider.class})>" + end + # This returns the SSH info for accessing this machine. This SSH info # is queried from the underlying provider. This method returns `nil` if # the machine is not ready for SSH communication.