Class: Docgenerator::Footnotegroup

Inherits:
Object
  • Object
show all
Defined in:
lib/docgenerator/footnote.rb

Overview

Footnotegroup.

A Footnote without group-attribute get it’s own Footnotegroup. For LaTeX it is ok, for HTML the content of the footnote will disappear.

Constant Summary collapse

DEFAULTGROUPID =

Define a default key for the footnotes. Used as part of the link.

'footnote'
@@all =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(groupid = DEFAULTGROUPID) ⇒ Footnotegroup

Build a new footnote group.



22
23
24
25
26
27
28
# File 'lib/docgenerator/footnote.rb', line 22

def initialize( groupid = DEFAULTGROUPID)
	@groupid		= groupid
	@footnotes	= []
	@attr		= {}
	@html_link	= true
   @@all[@groupid] = self
end

Instance Attribute Details

#groupidObject (readonly)

Returns the value of attribute groupid.



31
32
33
# File 'lib/docgenerator/footnote.rb', line 31

def groupid
  @groupid
end

Flag, if the footnote and the footnote mark should be linked.



30
31
32
# File 'lib/docgenerator/footnote.rb', line 30

def html_link
  @html_link
end

Class Method Details

.[](key = DEFAULTGROUPID) ⇒ Object



16
17
18
# File 'lib/docgenerator/footnote.rb', line 16

def self.[](key=DEFAULTGROUPID)
  @@all[key]
end

Instance Method Details

#<<(footnote) ⇒ Object



35
36
37
# File 'lib/docgenerator/footnote.rb', line 35

def <<( footnote )
	@footnotes	<< footnote unless @footnotes.include?(footnote)
end

#attr=(attr) ⇒ Object



32
33
34
# File 'lib/docgenerator/footnote.rb', line 32

def attr=( attr )
	@attr = attr
end

#sizeObject



38
39
40
# File 'lib/docgenerator/footnote.rb', line 38

def size()
	return @footnotes.size
end

#to_doc(target, options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/docgenerator/footnote.rb', line 41

def to_doc( target, options={} )
	return '' if @footnotes.empty?
	ul = element(:p, @attr ).cr
	@footnotes.each{|f|
		#~ ul << element(:sup, {}, f.counter )
		ul << footnotemark = element(:sup, { :log => options[:log] })
		if @html_link
			footnotemark  << element(:label, { :name => "#{f.link}", :log => options[:log] }, f.label )
		else
			footnotemark  << f.label
		end
		ul << f.get_content
		ul << element(:br).cr
	}
	return ul.to_doc(target, options )
end