Class: Sufia::CitationsBehaviors::Formatters::MlaFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- Sufia::CitationsBehaviors::Formatters::MlaFormatter
- Includes:
- PublicationBehavior, TitleBehavior
- Defined in:
- app/helpers/sufia/citations_behaviors/formatters/mla_formatter.rb
Constant Summary
Constants included from TitleBehavior
TitleBehavior::EXPANDED_NOCAPS, TitleBehavior::TITLE_NOCAPS
Instance Attribute Summary
Attributes inherited from BaseFormatter
Instance Method Summary collapse
- #format(work) ⇒ Object
- #format_authors(authors_list = []) ⇒ Object
- #format_date(pub_date) ⇒ Object
- #format_title(title_info) ⇒ Object
Methods included from TitleBehavior
#chicago_citation_title, #mla_citation_title, #process_title_parts, #setup_title_info
Methods included from CommonBehavior
#clean_end_punctuation, #persistent_url
Methods included from PublicationBehavior
#setup_pub_date, #setup_pub_info, #setup_pub_place, #setup_pub_publisher
Methods inherited from BaseFormatter
Methods included from NameBehavior
#abbreviate_name, #all_authors, #author_list, #given_name_first, #surname_first
Constructor Details
This class inherits a constructor from Sufia::CitationsBehaviors::Formatters::BaseFormatter
Instance Method Details
#format(work) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/sufia/citations_behaviors/formatters/mla_formatter.rb', line 8 def format(work) text = '' # setup formatted author list = (work).select { || !.blank? } text << "<span class=\"citation-author\">#{format_authors(authors)}</span>" # setup title title_info = setup_title_info(work) text << format_title(title_info) # Publication pub_info = clean_end_punctuation(setup_pub_info(work, true)) text << pub_info unless pub_info.blank? text << "." unless text.blank? || text =~ /\.$/ text.html_safe end |
#format_authors(authors_list = []) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/sufia/citations_behaviors/formatters/mla_formatter.rb', line 26 def ( = []) return "" if .blank? = Array.wrap() text = () unless text.blank? text << "." unless text =~ /\.$/ text << " " end text end |
#format_date(pub_date) ⇒ Object
54 55 56 |
# File 'app/helpers/sufia/citations_behaviors/formatters/mla_formatter.rb', line 54 def format_date(pub_date) pub_date end |
#format_title(title_info) ⇒ Object
58 59 60 |
# File 'app/helpers/sufia/citations_behaviors/formatters/mla_formatter.rb', line 58 def format_title(title_info) title_info.blank? ? "" : "<i class=\"citation-title\">#{mla_citation_title(title_info)}</i> " end |