Class: ReVIEW::EPUBMaker::ReVIEWHeaderListener
- Includes:
- REXML::StreamListener
- Defined in:
- lib/review/epubmaker.rb
Instance Method Summary collapse
-
#initialize(headlines) ⇒ ReVIEWHeaderListener
constructor
A new instance of ReVIEWHeaderListener.
- #tag_end(name) ⇒ Object
- #tag_start(name, attrs) ⇒ Object
- #text(text) ⇒ Object
Constructor Details
#initialize(headlines) ⇒ ReVIEWHeaderListener
Returns a new instance of ReVIEWHeaderListener.
510 511 512 513 514 |
# File 'lib/review/epubmaker.rb', line 510 def initialize(headlines) @level = nil @content = "" @headlines = headlines end |
Instance Method Details
#tag_end(name) ⇒ Object
532 533 534 535 536 537 538 539 |
# File 'lib/review/epubmaker.rb', line 532 def tag_end(name) if name =~ /\Ah\d+/ @headlines.push({"level" => @level, "id" => @id, "title" => @content}) unless @id.nil? @content = "" @level = nil @id = nil end end |
#tag_start(name, attrs) ⇒ Object
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/review/epubmaker.rb', line 516 def tag_start(name, attrs) if name =~ /\Ah(\d+)/ unless @level.nil? raise "#{name}, #{attrs}" end @level = $1.to_i @id = attrs["id"] if !attrs["id"].nil? elsif !@level.nil? if name == "img" && !attrs["alt"].nil? @content << attrs["alt"] elsif name == "a" && !attrs["id"].nil? @id = attrs["id"] end end end |
#text(text) ⇒ Object
541 542 543 544 545 |
# File 'lib/review/epubmaker.rb', line 541 def text(text) unless @level.nil? @content << text.gsub("\t", " ") # FIXME:区切り文字 end end |