Class: ModsDisplay::HTML
- Inherits:
-
Object
- Object
- ModsDisplay::HTML
- Defined in:
- lib/mods_display/html.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Need to figure out how to get the 1st title out of the list.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(config, xml, klass) ⇒ HTML
constructor
A new instance of HTML.
- #method_missing(method_name, *args, &block) ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(config, xml, klass) ⇒ HTML
Returns a new instance of HTML.
4 5 6 7 8 9 |
# File 'lib/mods_display/html.rb', line 4 def initialize(config, xml, klass) @config = config @stanford_mods = xml @xml = xml.mods_ng_xml @klass = klass end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/mods_display/html.rb', line 43 def method_missing(method_name, *args, &block) if to_s.respond_to?(method_name) to_html.send(method_name, *args, &block) elsif mods_display_fields.include?(method_name) mods_field(@xml, method_name).fields else super end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Need to figure out how to get the 1st title out of the list. Maybe have a separate class that will omit the first tite natively and replace the first key in the the fields list with that.
21 22 23 |
# File 'lib/mods_display/html.rb', line 21 def body @body end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/mods_display/html.rb', line 3 def title @title end |
Instance Method Details
#to_html ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/mods_display/html.rb', line 34 def to_html output = '<dl>' mods_display_fields.each do |field_key| field = mods_field(@xml, field_key) output << field.to_html unless field.nil? || field.to_html.nil? end output << '</dl>' end |