lib/labels/views/label/label_variable_fields.rb
# Single label - get variables from just this label.
Single label - get variables from just this label.
Single label - get variables from just this label .
def rules_for_single(obj, as_labels)
          doc       = Nokogiri::XML(obj.variable_xml)
          xml_vars  = doc.css('variable_field_count').map(&:text)
          vartypes  = clean_up_compound_variable_names(doc.css('variable variable_type'))
          combos    = Hash[xml_vars.zip(vartypes)]
          rules = {}
          yield rules
          xml_vars.each do |v|
            rules[:fields][v.to_sym] = if as_labels
                                         { renderer: :label, with_value: combos[v] }
                                       else
                                         { caption: "#{v} (#{combos[v]})" }
                                       end
          end
          [obj, rules, xml_vars]
        end
def rules_for_single ( obj , as_labels ) doc = Nokogiri :: XML ( obj . variable_xml ) xml_vars = doc . css ( 'variable_field_count' ) . map ( & :text ) vartypes = clean_up_compound_variable_names ( doc . css ( 'variable variable_type' ) ) combos = Hash [ xml_vars . zip ( vartypes ) ] rules = { } yield rules xml_vars . each do | v | rules [ :fields ] [ v . to_sym ] = if as_labels { renderer : :label , with_value : combos [ v ] } else { caption : "#{v} (#{combos[v]})" } end end [ obj , rules , xml_vars ] end
Single label - get variables from just this label.
Single label - get variables from just this label .
obj
<not_specific>
as_labels
<not_specific>