Class: Aozora2Html::MidashiCounter
- Inherits:
-
Object
- Object
- Aozora2Html::MidashiCounter
- Defined in:
- lib/aozora2html/midashi_counter.rb
Overview
見出しIDカウンター
主にmidashi_idを管理する
Instance Method Summary collapse
- #generate_id(size) ⇒ Object
-
#initialize(current_id) ⇒ MidashiCounter
constructor
A new instance of MidashiCounter.
Constructor Details
#initialize(current_id) ⇒ MidashiCounter
Returns a new instance of MidashiCounter.
8 9 10 |
# File 'lib/aozora2html/midashi_counter.rb', line 8 def initialize(current_id) @midashi_id = current_id end |
Instance Method Details
#generate_id(size) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/aozora2html/midashi_counter.rb', line 12 def generate_id(size) if size.is_a?(Integer) @midashi_id += size return @midashi_id end case size when /#{Aozora2Html::SIZE_SMALL}/o inc = 1 when /#{Aozora2Html::SIZE_MIDDLE}/o inc = 10 when /#{Aozora2Html::SIZE_LARGE}/o inc = 100 else raise Aozora2Html::Error, I18n.t(:undefined_header) end @midashi_id += inc end |