Class: ModsDisplay::HTML

Inherits:
Object
  • Object
show all
Defined in:
lib/mods_display/html.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, xml, klass) ⇒ HTML

Returns a new instance of HTML.



3
4
5
6
7
# File 'lib/mods_display/html.rb', line 3

def initialize(config, xml, klass)
  @config = config
  @xml = xml
  @klass = klass
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/mods_display/html.rb', line 41

def method_missing(method_name, *args, &block)
  if self.to_s.respond_to?(method_name)
    self.to_html.send(method_name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#bodyObject (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.



19
20
21
# File 'lib/mods_display/html.rb', line 19

def body
  @body
end

#titleObject (readonly)

Returns the value of attribute title.



2
3
4
# File 'lib/mods_display/html.rb', line 2

def title
  @title
end

Instance Method Details

#to_htmlObject



31
32
33
34
35
36
37
38
39
# File 'lib/mods_display/html.rb', line 31

def to_html
  output = "<dl>"
  mods_display_fields.each do |field_key|
    unless mods_field(@xml, field_key).to_html.nil?
      output << mods_field(@xml, field_key).to_html
    end
  end
  output << "</dl>"
end