Class: Deplate::Bib::Default
- Inherits:
-
CommonObject
- Object
- CommonObject
- Deplate::Bib::Default
- Defined in:
- lib/deplate/bib.rb
Class Method Summary collapse
-
.register_as(*names) ⇒ Object
def hook_post_style=(name) klass = self Deplate::Core.class_eval name) end.
Instance Method Summary collapse
- #bib_cite(invoker) ⇒ Object
- #bib_format(bibdef) ⇒ Object
-
#initialize(deplate) ⇒ Default
constructor
A new instance of Default.
Methods inherited from CommonObject
class_attribute, class_attributes, class_attributes=, class_attributes_ensure, class_meta_attributes, inherited, method_missing, respond_to?
Constructor Details
#initialize(deplate) ⇒ Default
Returns a new instance of Default.
36 37 38 |
# File 'lib/deplate/bib.rb', line 36 def initialize(deplate) @deplate = deplate end |
Class Method Details
Instance Method Details
#bib_cite(invoker) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/deplate/bib.rb', line 50 def bib_cite(invoker) container = invoker.container args = invoker.args n = args['n'] p = args['p'] ip = args['ip'] np = ip || args['np'] mode = args['mode'] y = args['y'] sep = args['sep'] || (np ? '' : ' ') acc = [] pmsg = @deplate.msg('p.\\ ') for c in invoker.elt cc = @deplate.formatter.bib_entry(c) if cc yr = cc['year'] || '' if p p = @deplate.parse_and_format_without_wikinames(container, "#{pmsg}#{p}") yr += ": #{p}" # yr += ": " + p if p end if y acc << referenced_bib_entry(invoker, c, yr) else nm = cc['author'] || cc['editor'] || cc['howpublished'] if nm if nm =~ /^\{(.*?)\}$/ nm = $1 else nm = nm.gsub(/\s+/, ' ').split(/ +and +/).collect do |a| a.scan(/\w+$/) end nm = nm.join(', ') end if ip acc << referenced_bib_entry(invoker, c, "#{nm} (#{yr})") else acc << referenced_bib_entry(invoker, c, [nm, yr].join(' ')) end else acc << referenced_bib_entry(invoker, c, c) end end end end n &&= n + @deplate.formatter.plain_text(' ', true) acc = acc.join('; ') sep = @deplate.formatter.plain_text(sep, true) if np return %{#{sep}#{n}#{acc}} else case mode when 'np' return %{#{sep}#{n}#{acc}} else return %{#{sep}(#{n}#{acc})} end end end |
#bib_format(bibdef) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/deplate/bib.rb', line 40 def bib_format(bibdef) type = bib_get_value(bibdef, '_type').downcase meth = "bib_#{type}" unless self.respond_to?(meth, true) meth = 'bib_default' end blocks = send(meth, bibdef) bib_join(blocks) end |