Bug #11103 ยป ruby-bug.rb
1 |
require 'JSON' |
---|---|
2 |
|
3 |
|
4 |
class MainClass |
5 |
attr_reader :mock_input |
6 |
|
7 |
def initialize(input) |
8 |
puts "hello" |
9 |
|
10 |
@mock_input = input |
11 |
|
12 |
# Print with JSON or puts
|
13 |
puts "-------" |
14 |
if (mock_input.is_a?(Array)) |
15 |
puts JSON.pretty_generate mock_input |
16 |
else
|
17 |
puts mock_input |
18 |
end
|
19 |
puts "-------" |
20 |
|
21 |
if (!mock_input.is_a?(Array)) |
22 |
puts "Converting to array..." |
23 |
mock_input = [mock_input] |
24 |
end
|
25 |
|
26 |
# Print with JSON or puts
|
27 |
puts "-------" |
28 |
if (mock_input.is_a?(Array)) |
29 |
puts JSON.pretty_generate mock_input |
30 |
else
|
31 |
puts mock_input |
32 |
end
|
33 |
puts "-------" |
34 |
end
|
35 |
end
|
36 |
|
37 |
MainClass.new ["hello", "world"] |