Method: Utils::ConfigFile::BlockConfig#to_ruby

Defined in:
lib/utils/config_file.rb

#to_ruby(depth = 0) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/utils/config_file.rb', line 65

def to_ruby(depth = 0)
  result = ''
  result << ' ' * 2 * depth <<
    "#{self.class.name[/::([^:]+)\z/, 1].underscore} do\n"
  for name in self.class.config_settings
    value = __send__(name)
    if value.respond_to?(:to_ruby)
      result << ' ' * 2 * (depth + 1) << value.to_ruby(depth + 1)
    else
      result << ' ' * 2 * (depth + 1) <<
        "#{name} #{Array(value).map(&:inspect) * ', '}\n"
    end
  end
  result << ' ' * 2 * depth << "end\n"
end