Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- settings => {
- "var1" =>
- {
- "ip" => "0.0.0.0",
- "port" => "1234",
- "option" => ["foo", "bar"],
- "machines" =>
- {
- "maschine-1" => { "ip" => "1.2.3.4", "port" => "1234"},
- "maschine-2" => { "ip" => "1.2.3.5", "port" => "1235"},
- }
- }
- }
- var1 {
- ip "0.0.0.0";
- port "1234";
- option ["foo", "bar"];
- machines {
- maschine-1 {
- ip "1.2.3.4";
- port "1234";
- }
- maschine-2 {
- ip "1.2.3.5";
- port "1235";
- }
- }
- }
- <% print_function = Proc.new do |h,spaces=0,level=0| -%>
- <% h.each do |key,val| -%>
- <% format = "#{' '*spaces*level}#{key}" -%>
- <% if val.is_a? Hash -%>
- <%= "#{format} {" %>
- <% print_function.call(val,spaces,level+1) -%>
- <%= "#{' '*spaces*level}}" %>
- <% else -%>
- <% if val.is_a? Array -%>
- <%= "#{format}" + " " + val.to_s + ";" %>
- <% else -%>
- <%= "#{format}" + " "" + val.to_s + "";" %>
- <% end -%>
- <% end -%>
- <% end -%>
- <% end -%>
- <% print_function.call(@settings,2,0) -%>
Add Comment
Please, Sign In to add comment