Module: Hyrax::CitationsBehaviors::PublicationBehavior

Includes:
CommonBehavior
Included in:
Hyrax::CitationsBehavior, Formatters::ApaFormatter, Formatters::ChicagoFormatter, Formatters::MlaFormatter
Defined in:
app/helpers/hyrax/citations_behaviors/publication_behavior.rb

Instance Method Summary collapse

Methods included from CommonBehavior

#clean_end_punctuation, #persistent_url

Instance Method Details

#setup_pub_date(work) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'app/helpers/hyrax/citations_behaviors/publication_behavior.rb', line 5

def setup_pub_date(work)
  first_date = work.date_created.first if work.date_created
  unless first_date.blank?
    first_date = CGI.escapeHTML(first_date)
    date_value = first_date.gsub(/[^0-9|n\.d\.]/, "")[0, 4]
    return nil if date_value.nil?
  end
  clean_end_punctuation(date_value) if date_value
end

#setup_pub_info(work, include_date = false) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/helpers/hyrax/citations_behaviors/publication_behavior.rb', line 23

def setup_pub_info(work, include_date = false)
  pub_info = ""
  if (place = setup_pub_place(work))
    pub_info << CGI.escapeHTML(place)
  end
  if (publisher = setup_pub_publisher(work))
    pub_info << ": " << CGI.escapeHTML(publisher)
  end

  pub_date = include_date ? setup_pub_date(work) : nil
  pub_info << ", " << pub_date unless pub_date.nil?

  pub_info.strip!
  pub_info.blank? ? nil : pub_info
end

#setup_pub_place(work) ⇒ Object



15
16
17
# File 'app/helpers/hyrax/citations_behaviors/publication_behavior.rb', line 15

def setup_pub_place(work)
  work.based_near.first if work.based_near
end

#setup_pub_publisher(work) ⇒ Object



19
20
21
# File 'app/helpers/hyrax/citations_behaviors/publication_behavior.rb', line 19

def setup_pub_publisher(work)
  work.publisher.first if work.publisher
end