Class: Chef::RubyCompat::RubyIO
- Inherits:
-
Object
- Object
- Chef::RubyCompat::RubyIO
- Defined in:
- lib/chef/ruby_compat.rb
Constant Summary collapse
- @@inspector =
AwesomePrint::Inspector.new :plain => true, :indent => 2, :index => false
Instance Method Summary collapse
- #format(obj) ⇒ Object
-
#initialize ⇒ RubyIO
constructor
A new instance of RubyIO.
- #new_line ⇒ Object
- #string ⇒ Object
- #write(string) ⇒ Object
- #write_method(method_name, *args) ⇒ Object
Constructor Details
#initialize ⇒ RubyIO
Returns a new instance of RubyIO.
105 106 107 |
# File 'lib/chef/ruby_compat.rb', line 105 def initialize @out = StringIO.new end |
Instance Method Details
#format(obj) ⇒ Object
142 143 144 |
# File 'lib/chef/ruby_compat.rb', line 142 def format(obj) @@inspector.awesome obj end |
#new_line ⇒ Object
130 131 132 |
# File 'lib/chef/ruby_compat.rb', line 130 def new_line write "\n" end |
#string ⇒ Object
138 139 140 |
# File 'lib/chef/ruby_compat.rb', line 138 def string @out.string end |
#write(string) ⇒ Object
134 135 136 |
# File 'lib/chef/ruby_compat.rb', line 134 def write(string) @out.write string end |
#write_method(method_name, *args) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/chef/ruby_compat.rb', line 109 def write_method(method_name, *args) write method_name write("(") arg_values = args.map do |arg| if arg.is_a? String arg.inspect elsif arg.is_a? Hash format(arg) else raise "Object type [#{arg.class.name}] is not supported" end end write(arg_values.join(", ")) write(")") new_line end |