Class: MathMetadata::Author
- Defined in:
- lib/math_metadata_lookup/author.rb
Overview
Attributes
-
:id [String] an id of the article in the database
-
:preferred [String] a preferred form of name in the database
-
:forms [Array of Strings] other name forms
Instance Method Summary collapse
Methods inherited from Entity
#[], #[]=, #format, #initialize, #method_missing
Constructor Details
This class inherits a constructor from MathMetadata::Entity
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class MathMetadata::Entity
Instance Method Details
#to_html ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/math_metadata_lookup/author.rb', line 36 def to_html result = %~ <div class="author"> <div class="author_id"><span class="label">Id:</span> <span class="id">#{::CGI.escapeHTML(@metadata[:id])}</span></div> <div class="preferred"><span class="label">Preferred:</span> <span class="name">#{::CGI.escapeHTML(@metadata[:preferred].to_s)}</span></div>~ @metadata[:forms].each do |form| result += %~ <div class="other"><span class="label">Other:</span> <span class="name">#{::CGI.escapeHTML(form.to_s)}</span></div>~ end result += %~ </div> ~ result end |
#to_text ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/math_metadata_lookup/author.rb', line 10 def to_text result = %~Id: #{@metadata[:id]}\nPreferred: #{@metadata[:preferred]}~ @metadata[:forms].to_a.each do |form| result += %~ Other: #{form}~ end result += "\n\n" result end |
#to_xml ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/math_metadata_lookup/author.rb', line 21 def to_xml result = %~ <author id="#{::CGI.escapeHTML(@metadata[:id])}"> <name form="preferred">#{::CGI.escapeHTML(@metadata[:preferred].to_s)}</name>~ @metadata[:forms].each do |form| result += %~ <name form="other">#{::CGI.escapeHTML(form.to_s)}</name>~ end result += %~ </author> ~ result end |