title: Is there a ruby-er way to do these assignments?
body: <p>I am trying to read Sonar report in XML format using ruby. I have written the following code:</p>
  
  <pre><code>class Resource
      attr_accessor :file_name, :lines, :generated_lines, :ncloc, :generated_ncloc, :statements, :comment_lines, :commented_out_code_lines, :lines_to_cover, :uncovered_lines, :conditions_to_cover, :uncovered_conditions, :line_coverage, :branch_coverage, :coverage, :test_success_density, :test_failures, :skipped_tests, :test_errors, :num_of_tests, :lang, :qualifier
  
      def to_s
          "#{@name} #{@lines} #{@generated_lines} #{@ncloc} #{@generated_ncloc} #{@statements} #{@comment_lines} #{@commented_out_code_lines} #{@lines_to_cover} #{@uncovered_lines} #{@conditions_to_cover} #{@uncovered_conditions} #{@line_coverage} #{@branch_coverage} #{@coverage} #{@test_success_density} #{@test_failures} #{@skipped_tests} #{@test_errors}#{@num_of_tests} #{@lang} #{@qualifier}"
      end 
  end
  
  
  sonar.root.each_element do |node1| # resources
      next if node1.name != "resources"
      node1.each_element do |node2| #resource
          resource = Resource.new
          resource.lang = node2.text if node2.name == "lang"
          resource.qualifier = node2.text if node2.name == "qualifier"
          resource.name = node.text if node2.name == "name"
      end
  end
  </code></pre>
  
  <p>As you can see this takes up too many statements whether I use <code>if</code> conditionals or <code>case</code> statements. Is there a more succinct way of doing this in ruby?</p>