Module: RubyCurses::ModStack

Defined in:
lib/rbcurse/core/util/basestack.rb

Defined Under Namespace

Classes: BaseStack, Flow, Item, Stack

Instance Method Summary collapse

Instance Method Details

#each(&block) ⇒ Object

traverse the components and their children



304
305
306
# File 'lib/rbcurse/core/util/basestack.rb', line 304

def each &block
  @components.each { |e| traverse e, &block }
end

#flow(config = {}, &block) ⇒ Object



343
344
345
# File 'lib/rbcurse/core/util/basestack.rb', line 343

def flow config={}, &block
  _stack :flow, config, &block
end

#item_for(widget) ⇒ Object

given an widget, return the item, so we can change weight or some other config



387
388
389
390
391
392
393
394
395
396
# File 'lib/rbcurse/core/util/basestack.rb', line 387

def item_for widget
  each do |e|
    if e.is_a? Item
      if e.widget == widget
        return e
      end
    end
  end
  return nil
end

#parent_of(widget) ⇒ Object

module level returns the parent (flow or stack) for a given widget

allowing user to change configuration such as weight


400
401
402
403
404
# File 'lib/rbcurse/core/util/basestack.rb', line 400

def parent_of widget
  f = item_for widget
  return f.config[:parent] if f
  return nil
end

#stack(config = {}, &block) ⇒ Object



340
341
342
# File 'lib/rbcurse/core/util/basestack.rb', line 340

def stack config={}, &block
  _stack :stack, config, &block
end

#traverse(c, &block) ⇒ Object

General routin to traverse components and their components



290
291
292
293
294
295
296
297
298
299
300
# File 'lib/rbcurse/core/util/basestack.rb', line 290

def traverse c, &block
  if c.is_a? BaseStack
    yield c
    c.components.each { |e| 
      yield e
    }
    c.components.each { |e| traverse(e, &block)  }
    @ctr -= 1
  else
  end
end