Class: ReferenceKey
- Inherits:
-
Object
- Object
- ReferenceKey
- Includes:
- ActionView::Context, ActionView::Helpers::TagHelper
- Defined in:
- app/models/reference_key.rb
Instance Method Summary (collapse)
-
- (ReferenceKey) initialize(reference)
constructor
A new instance of ReferenceKey.
- - (Object) to_link(user)
- - (Object) to_s
- - (Object) to_taxt
Constructor Details
- (ReferenceKey) initialize(reference)
A new instance of ReferenceKey
6 7 8 |
# File 'app/models/reference_key.rb', line 6 def initialize reference @reference = reference end |
Instance Method Details
- (Object) to_link(user)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/reference_key.rb', line 27 def to_link user content_tag(:span, :class => :reference_key_and_expansion) do content_tag(:a, to_s, :href => '#', :class => :reference_key) + content_tag(:span, :class => :reference_key_expansion) do content = content_tag(:span, Formatters::ReferenceFormatter.format(@reference), class: :reference_key_expansion_text) document_link = Formatters::CatalogFormatter.format_reference_document_link @reference, user content << document_link if document_link content << "<a class=\"goto_reference_link\" target=\"_blank\" href=\"/references?q=#{@reference.id}\">".html_safe content << content_tag(:img, '', :src => "/images/external_link.png") content << "</a>".html_safe content.html_safe end end end |
- (Object) to_s
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/reference_key.rb', line 14 def to_s names = @reference..map &:last_name case when names.size == 1 "#{names.first}, " when names.size == 2 "#{names.first} & #{names.second}, " else string = names[0..-2].join ', ' string << " & " << names[-1] << ', ' end << @reference.short_citation_year end |
- (Object) to_taxt
10 11 12 |
# File 'app/models/reference_key.rb', line 10 def to_taxt Taxt.encode_reference @reference end |