Class: Fold::AbstractFold

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/fold/abstract_fold.rb

Constant Summary collapse

Regex =
//

Instance Method Summary collapse

Constructor Details

#initialize(source = {}) ⇒ AbstractFold

Returns a new instance of AbstractFold.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fold/abstract_fold.rb', line 6

def initialize source={}
  attrs= {
    :text => '',
    :children => [],
    :tabs => -1
  }.merge(source)

  attrs[:text].gsub! self.class::Regex, '' if self.class.clear_match
  
  super attrs
end

Instance Method Details

#renderObject



18
19
20
# File 'lib/fold/abstract_fold.rb', line 18

def render
  text
end

#render_childrenObject



22
23
24
# File 'lib/fold/abstract_fold.rb', line 22

def render_children
  children.map{|child| child.render}
end