Class: PPZ::AbstractWrapperModel

Inherits:
AbstractModel show all
Defined in:
lib/doc/model/abstract/wrapper-model.rb

Instance Attribute Summary

Attributes inherited from AbstractModel

#father_model, #index, #left_model, #right_model

Instance Method Summary collapse

Methods inherited from AbstractModel

from_line, #transform_inline_element

Constructor Details

#initializeAbstractWrapperModel

Returns a new instance of AbstractWrapperModel.



2
3
4
# File 'lib/doc/model/abstract/wrapper-model.rb', line 2

def initialize
  @children = []
end

Instance Method Details

#append(el) ⇒ Object

把 el 加入到 children



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/doc/model/abstract/wrapper-model.rb', line 7

def append el
  el.father_model = self

  left_model = @children[-1]
  if left_model
    left_model.right_model = el
    el.left_model = el
    el.index = left_model.index + 1
  else
    el.index = 1
  end
  @children.push el
end

#to_htmlObject



21
22
23
24
25
# File 'lib/doc/model/abstract/wrapper-model.rb', line 21

def to_html
  @children
    .map { |child| child.to_html }
    .join
end