Module: PublishMyData::DatasetsHelper

Defined in:
app/helpers/publish_my_data/datasets_helper.rb

Instance Method Summary collapse

Instance Method Details

#example_resource_for_type(dataset, type) ⇒ Object



23
24
25
# File 'app/helpers/publish_my_data/datasets_helper.rb', line 23

def example_resource_for_type(dataset, type)
  dataset.example_resources.detect {|r| r.rdf_type.include?(type.uri) }
end

#formatted_date(date_string) ⇒ Object



3
4
5
6
7
8
9
# File 'app/helpers/publish_my_data/datasets_helper.rb', line 3

def formatted_date(date_string)
  unless date_string.blank?
    DateTime.parse(date_string).to_s(:long)
  else 
    date_string
  end
end

#types_for_example_resource(dataset, example_resource) ⇒ Object



27
28
29
# File 'app/helpers/publish_my_data/datasets_helper.rb', line 27

def types_for_example_resource(dataset, example_resource)
  dataset.types.select {|t| example_resource.rdf_type.include?(t.uri) }
end

#vocabulary_class(dataset, uri) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/publish_my_data/datasets_helper.rb', line 11

def vocabulary_class(dataset, uri)
  dataset.ontologies.each_with_index do |ontology, index|
    uris = ontology.classes.map(&:uri) + ontology.properties.map(&:uri)
    return "ontology_#{index}" if uris.any?{|u| uri == u}
  end
  dataset.concept_schemes.each_with_index do |concept_scheme, index|
    uris = concept_scheme.concepts.map(&:uri)
    return "concept_scheme_#{index}" if uris.any?{|u| uri == u}
  end
  return ''
end