Module: Summon::Refworks::Builder
- Defined in:
- lib/summon/refworks.rb
Class Method Summary collapse
Instance Method Summary collapse
- #content_type_to_reference_type ⇒ Object
- #refworks_normal(value) ⇒ Object
- #refworks_tags ⇒ Object
- #to_refworks_tagged_format(options) ⇒ Object
Class Method Details
.build(document, options) ⇒ Object
23 24 25 26 |
# File 'lib/summon/refworks.rb', line 23 def self.build(document, ) document.extend self document.to_refworks_tagged_format end |
Instance Method Details
#content_type_to_reference_type ⇒ Object
41 42 43 44 |
# File 'lib/summon/refworks.rb', line 41 def content_type_to_reference_type mapping = YAML.load(File.read File.("../RT.yaml", __FILE__)) mapping[content_type] || 'Generic' end |
#refworks_normal(value) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/summon/refworks.rb', line 33 def refworks_normal(value) if value.kind_of?(Array) value.tag_per_value? ? value : [value.join(', ')] else [value] end.compact end |
#refworks_tags ⇒ Object
28 29 30 31 |
# File 'lib/summon/refworks.rb', line 28 def filename = File.("../mappings.rb", __FILE__) eval(File.read(filename), binding, filename, 1) end |
#to_refworks_tagged_format(options) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/summon/refworks.rb', line 46 def to_refworks_tagged_format() {}.tap do || .merge().each do |tag, mapping| [tag] = refworks_normal case mapping when Symbol then send(mapping) when Proc then mapping.call() else mapping; end end end end |