Class: HTML2FB::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/Html2Feedbooks/document.rb,
lib/Html2Feedbooks/feedbooks.rb

Direct Known Subclasses

Document

Constant Summary collapse

@@level =
0
@@types =
['Part','Chapter','Section']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSection

Returns a new instance of Section.



8
9
10
# File 'lib/Html2Feedbooks/document.rb', line 8

def initialize
	@content=[]
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



5
6
7
# File 'lib/Html2Feedbooks/document.rb', line 5

def content
  @content
end

#fblevelObject

Returns the value of attribute fblevel.



6
7
8
# File 'lib/Html2Feedbooks/document.rb', line 6

def fblevel
  @fblevel
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/Html2Feedbooks/document.rb', line 4

def title
  @title
end

Instance Method Details

#decorated_titleObject



16
17
18
19
20
21
22
# File 'lib/Html2Feedbooks/document.rb', line 16

def decorated_title
	unless fblevel.nil?
		"[#{fblevel}] "+title
	else
		title
	end
end

#old_to_htmlObject



92
93
94
# File 'lib/Html2Feedbooks/feedbooks.rb', line 92

def to_html
	content.collect{|e|e.to_html}.join
end

#titlesObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/Html2Feedbooks/document.rb', line 24

def titles
	tit=[]
	content.each do |f|
#				if f.is_a?Section
			tit.push f.titles
#				else
#					tit.push '#text'
#				end
	end

	return [decorated_title,tit]
end

#to_feedbooks(conf, path = nil) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/Html2Feedbooks/feedbooks.rb', line 79

def to_feedbooks(conf,path=nil)
	type=self.fblevel.to_s.downcase.strip.capitalize
	unless @@types.include?type
		type=@@types[@@level]||@@types[-1]
	end
	fbpath=FBPost.push(conf,title,'',type,path)
	@@level+=1
	content.each do |e|
		e.to_feedbooks(conf,fbpath)
	end
	@@level-=1
end

#to_htmlObject



12
13
14
# File 'lib/Html2Feedbooks/document.rb', line 12

def to_html
	content.collect{|e|e.to_html}.join
end

#to_sObject



37
38
39
# File 'lib/Html2Feedbooks/document.rb', line 37

def to_s
	return "title :#{title}  \n"+content.collect{|a|a.to_s}.join("\n\n")
end