Class: MathMetadata::Author

Inherits:
Entity
  • Object
show all
Defined in:
lib/math_metadata_lookup/author.rb

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_htmlObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/math_metadata_lookup/author.rb', line 31

def to_html
  result = %~
<div class="author">
    <div class="author_id">Id: #{::CGI.escapeHTML(@metadata[:id])}</div>
    <div class="preferred">Preferred: #{::CGI.escapeHTML(@metadata[:preferred].to_s)}</div>~

  @metadata[:forms].each do |form|
      result += %~
    <div class="other">Other: #{::CGI.escapeHTML(form.to_s)}</div>~
  end

  result += %~
</div>
~
  result
end

#to_textObject



5
6
7
8
9
10
11
12
13
# File 'lib/math_metadata_lookup/author.rb', line 5

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_xmlObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/math_metadata_lookup/author.rb', line 16

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