Module: RubyCurses::ModStack

Defined in:
lib/rbhex/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



308
309
310
# File 'lib/rbhex/core/util/basestack.rb', line 308

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

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



347
348
349
# File 'lib/rbhex/core/util/basestack.rb', line 347

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



391
392
393
394
395
396
397
398
399
400
# File 'lib/rbhex/core/util/basestack.rb', line 391

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


404
405
406
407
408
# File 'lib/rbhex/core/util/basestack.rb', line 404

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

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



344
345
346
# File 'lib/rbhex/core/util/basestack.rb', line 344

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

#traverse(c, &block) ⇒ Object

General routin to traverse components and their components



294
295
296
297
298
299
300
301
302
303
304
# File 'lib/rbhex/core/util/basestack.rb', line 294

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