Class: Dyndoc::Ruby::BlckMngr

Inherits:
Object
  • Object
show all
Defined in:
lib/dyndoc/base/tmpl/extension.rb

Overview

this is an attempt to offer an interface for running on a block tree. usefull for user adding dtag.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tmplMngr, blck, tex, filter) ⇒ BlckMngr

Returns a new instance of BlckMngr.



13
14
15
16
17
# File 'lib/dyndoc/base/tmpl/extension.rb', line 13

def initialize(tmplMngr,blck,tex,filter)
  @tmplMngr,@blck,@pos=tmplMngr,blck,0
  @tex,@filter=tex,filter
  @children=[] #the blocks
end

Instance Attribute Details

#blckObject (readonly)

Returns the value of attribute blck.



11
12
13
# File 'lib/dyndoc/base/tmpl/extension.rb', line 11

def blck
  @blck
end

#childrenObject (readonly)

Returns the value of attribute children.



11
12
13
# File 'lib/dyndoc/base/tmpl/extension.rb', line 11

def children
  @children
end

#filterObject (readonly)

Returns the value of attribute filter.



11
12
13
# File 'lib/dyndoc/base/tmpl/extension.rb', line 11

def filter
  @filter
end

#tmplMngrObject (readonly)

Returns the value of attribute tmplMngr.



11
12
13
# File 'lib/dyndoc/base/tmpl/extension.rb', line 11

def tmplMngr
  @tmplMngr
end

Instance Method Details

#<<(content) ⇒ Object



34
35
36
37
# File 'lib/dyndoc/base/tmpl/extension.rb', line 34

def <<(content)
  @tex << content
  return self
end

#[](i) ⇒ Object



59
60
61
# File 'lib/dyndoc/base/tmpl/extension.rb', line 59

def [](i)
  @blck[i]
end

#at_end?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/dyndoc/base/tmpl/extension.rb', line 51

def at_end?
  @pos == @blck.length-1
end

#child(i = -1)) ⇒ Object



75
76
77
# File 'lib/dyndoc/base/tmpl/extension.rb', line 75

def child(i=-1)
  @children[i]
end

#child_as_varObject



140
141
142
143
# File 'lib/dyndoc/base/tmpl/extension.rb', line 140

def child_as_var
  b=@tmplMngr.make_var_block(child.unshift(:var),@filter)
  @tmplMngr.eval_VARS(b,@filter)
end

#goto_next_child!Object



94
95
96
97
98
99
# File 'lib/dyndoc/base/tmpl/extension.rb', line 94

def goto_next_child!
  unless @gone
    @pos+=@children[-1].length
    @gone=true #only once!
  end
end

#lengthObject



47
48
49
# File 'lib/dyndoc/base/tmpl/extension.rb', line 47

def length
  @blck.length
end

#next_at_end?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/dyndoc/base/tmpl/extension.rb', line 55

def next_at_end?
  @pos == @blck.length-2
end

#next_childObject



88
89
90
91
92
# File 'lib/dyndoc/base/tmpl/extension.rb', line 88

def next_child
  b=next_child_at(@pos)
  @gone=nil
  return b
end

#next_child!Object



101
102
103
104
105
# File 'lib/dyndoc/base/tmpl/extension.rb', line 101

def next_child!
  @children << next_child
  goto_next_child!
  return child
end

#next_child_at(pos) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/dyndoc/base/tmpl/extension.rb', line 79

def next_child_at(pos)
  b,i=[],pos
  while (i+1<@blck.length and @blck[i+1].is_a? Array)
    i+=1
    b << @blck[i]
  end
  return b
end

#next_child_until(tagset) ⇒ Object



107
108
109
110
111
112
113
114
115
116
# File 'lib/dyndoc/base/tmpl/extension.rb', line 107

def next_child_until(tagset)
  b,i=[],@pos
  #p @blck
  while (i+1<@blck.length and !(tagset.include? @blck[i+1]))
   i += 1
   b << @blck[i]
  end
  @gone=nil
  return b
end

#next_child_until!(tagset) ⇒ Object



118
119
120
121
122
# File 'lib/dyndoc/base/tmpl/extension.rb', line 118

def next_child_until!(tagset)
  @children << next_child_until(tagset)
  goto_next_child!
  return child
end

#next_child_while(tagset) ⇒ Object



124
125
126
127
128
129
130
131
132
# File 'lib/dyndoc/base/tmpl/extension.rb', line 124

def next_child_while(tagset)
  b,i=[],@pos
  while (i+1<@blck.length and (tagset.include? @blck[i+1]))
   i+=1
   b << @blck[i]
  end
  @gone=nil
  return b
end

#next_child_while!(tagset) ⇒ Object



134
135
136
137
138
# File 'lib/dyndoc/base/tmpl/extension.rb', line 134

def next_child_while!(tagset)
  @children << next_child_while(tagset)
  goto_next_child!
  return child
end

#next_tagObject



67
68
69
# File 'lib/dyndoc/base/tmpl/extension.rb', line 67

def next_tag
  @blck[@pos+1]
end

#next_tag!Object



71
72
73
# File 'lib/dyndoc/base/tmpl/extension.rb', line 71

def next_tag!
  @blck[@pos+=1]
end

#parse(blck = @blck, filter = @filter) ⇒ Object



23
24
25
26
27
28
# File 'lib/dyndoc/base/tmpl/extension.rb', line 23

def parse(blck=@blck,filter=@filter)
  ##Dyndoc.warn "parse!!!",blck
  res=@tmplMngr.parse(blck,filter)
  ##Dyndoc.warn "result parse",res
  res
end

#parse!(blck = @blck, filter = @filter) ⇒ Object



30
31
32
# File 'lib/dyndoc/base/tmpl/extension.rb', line 30

def parse!(blck=@blck,filter=@filter)
  self << parse(blck,filter)
end

#parse_child(filter = @filter) ⇒ Object



19
20
21
# File 'lib/dyndoc/base/tmpl/extension.rb', line 19

def parse_child(filter=@filter)
  @tmplMngr.parse(child,filter)
end

#posObject



43
44
45
# File 'lib/dyndoc/base/tmpl/extension.rb', line 43

def pos
  @pos
end

#pos=(i) ⇒ Object



39
40
41
# File 'lib/dyndoc/base/tmpl/extension.rb', line 39

def pos=(i)
  @pos=i
end

#tagObject



63
64
65
# File 'lib/dyndoc/base/tmpl/extension.rb', line 63

def tag
  @blck[@pos]
end