Class: HTML2FB::Section
- Inherits:
-
Object
- Object
- HTML2FB::Section
- Defined in:
- lib/Html2Feedbooks/document.rb,
lib/Html2Feedbooks/feedbooks.rb
Direct Known Subclasses
Constant Summary collapse
- @@level =
0
- @@types =
['Part','Chapter','Section']
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#fblevel ⇒ Object
Returns the value of attribute fblevel.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #decorated_title ⇒ Object
-
#initialize ⇒ Section
constructor
A new instance of Section.
- #old_to_html ⇒ Object
- #titles ⇒ Object
- #to_feedbooks(conf, path = nil) ⇒ Object
- #to_html ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Section
Returns a new instance of Section.
8 9 10 |
# File 'lib/Html2Feedbooks/document.rb', line 8 def initialize @content=[] end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
5 6 7 |
# File 'lib/Html2Feedbooks/document.rb', line 5 def content @content end |
#fblevel ⇒ Object
Returns the value of attribute fblevel.
6 7 8 |
# File 'lib/Html2Feedbooks/document.rb', line 6 def fblevel @fblevel end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/Html2Feedbooks/document.rb', line 4 def title @title end |
Instance Method Details
#decorated_title ⇒ Object
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_html ⇒ Object
92 93 94 |
# File 'lib/Html2Feedbooks/feedbooks.rb', line 92 def to_html content.collect{|e|e.to_html}.join end |
#titles ⇒ Object
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_html ⇒ Object
12 13 14 |
# File 'lib/Html2Feedbooks/document.rb', line 12 def to_html content.collect{|e|e.to_html}.join end |
#to_s ⇒ Object
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 |