class PPZ::LeafSectionModel
Constants
- REG_EXP
Attributes
level[RW]
section_dom_id[RW]
title[RW]
Public Class Methods
from_line(line)
click to toggle source
# File lib/doc/model/section/leaf.rb, line 12 def self.from_line line return nil unless REG_EXP.match(line) level = { 1 => 1, # 一个井号是 一级 5 => 3 # 五个井号是 三级 }[$1.size] || 2 # 其余都是 两级 PPZ::LeafSectionModel.new $2, level end
new(title, level)
click to toggle source
Calls superclass method
PPZ::AbstractWrapperModel::new
# File lib/doc/model/section/leaf.rb, line 4 def initialize title, level raise TypeError unless title.is_a?(String) && level.is_a?(Integer) super() # 不可以省略括号 @title = transform_inline_element title @level = level end
Public Instance Methods
to_html()
click to toggle source
# File lib/doc/model/section/leaf.rb, line 26 def to_html "<section id=#{@section_dom_id}><h#{@level}>#{@title}</h#{@level}>#{super}</section>" end