Guest User

Untitled

a guest
Jan 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. settings => {
  2. "var1" =>
  3. {
  4. "ip" => "0.0.0.0",
  5. "port" => "1234",
  6. "option" => ["foo", "bar"],
  7. "machines" =>
  8. {
  9. "maschine-1" => { "ip" => "1.2.3.4", "port" => "1234"},
  10. "maschine-2" => { "ip" => "1.2.3.5", "port" => "1235"},
  11. }
  12. }
  13. }
  14.  
  15. var1 {
  16. ip "0.0.0.0";
  17. port "1234";
  18. option ["foo", "bar"];
  19. machines {
  20. maschine-1 {
  21. ip "1.2.3.4";
  22. port "1234";
  23. }
  24. maschine-2 {
  25. ip "1.2.3.5";
  26. port "1235";
  27. }
  28. }
  29. }
  30.  
  31. <% print_function = Proc.new do |h,spaces=0,level=0| -%>
  32. <% h.each do |key,val| -%>
  33. <% format = "#{' '*spaces*level}#{key}" -%>
  34. <% if val.is_a? Hash -%>
  35. <%= "#{format} {" %>
  36. <% print_function.call(val,spaces,level+1) -%>
  37. <%= "#{' '*spaces*level}}" %>
  38. <% else -%>
  39. <% if val.is_a? Array -%>
  40. <%= "#{format}" + " " + val.to_s + ";" %>
  41. <% else -%>
  42. <%= "#{format}" + " "" + val.to_s + "";" %>
  43. <% end -%>
  44. <% end -%>
  45. <% end -%>
  46. <% end -%>
  47. <% print_function.call(@settings,2,0) -%>
Add Comment
Please, Sign In to add comment