app/models/trait.rb
# Returns a hash of metadata. Values are always arrays, because metadata CAN
# have one predicate with multiple values.
Returns a hash of metadata. Values are always arrays, because metadata CAN
have one predicate with multiple values.
Returns a hash of metadata . Values are always arrays because metadata CAN have one predicate with multiple values .
def meta
    return @meta if @meta
    @meta = {}
    rdf_with_meta_units.
         each do |rdf|
      pred = rdf[:trait_predicate].to_s
      pred = glossary.find { |g| g.uri == pred } || pred
      m_units = rdf_meta_units(rdf[:value].to_s)
      m_units = glossary.find { |g| g.uri == m_units } || m_units
      val = rdf[:meta_value].to_s
      val = glossary.find { |g| g.uri == val } || val
      @meta[pred] ||= []
      @meta[pred] << { value: val, units: m_units }
    end
    rdf_without_meta_units.each do |rdf|
      pred = rdf[:trait_predicate].to_s
      next if pred == TraitBank.type_uri
      next if pred == TraitBank.value_uri
      next if association_redundancies.include?(pred)
      val = rdf[:value].to_s
      next if val =~ SOURCE_RE
      pred = glossary.find { |g| g.uri == pred } || pred
      val = glossary.find { |g| g.uri == val } || val
      @meta[pred] ||= []
      @meta[pred] << val
    end
    @meta
  end
def meta return @meta if @meta @meta = { } rdf_with_meta_units . each do | rdf | pred = rdf [ :trait_predicate ] . to_s pred = glossary . find { | g | g . uri == pred } || pred m_units = rdf_meta_units ( rdf [ :value ] . to_s ) m_units = glossary . find { | g | g . uri == m_units } || m_units val = rdf [ :meta_value ] . to_s val = glossary . find { | g | g . uri == val } || val @meta [ pred ] ||= [ ] @meta [ pred ] << { value : val , units : m_units } end rdf_without_meta_units . each do | rdf | pred = rdf [ :trait_predicate ] . to_s next if pred == TraitBank . type_uri next if pred == TraitBank . value_uri next if association_redundancies . include? ( pred ) val = rdf [ :value ] . to_s next if val =~ SOURCE_RE pred = glossary . find { | g | g . uri == pred } || pred val = glossary . find { | g | g . uri == val } || val @meta [ pred ] ||= [ ] @meta [ pred ] << val end @meta end
Returns a hash of metadata.
Returns a hash of metadata .
# Skip type of row: # Skip the value (that's already shown): # Skip association redundancies: # Skip resource as "source"