Module: RubyCurses::ModStack

Included in:
StackFlow
Defined in:
lib/canis/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



310
311
312
# File 'lib/canis/core/util/basestack.rb', line 310

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

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



349
350
351
# File 'lib/canis/core/util/basestack.rb', line 349

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



393
394
395
396
397
398
399
400
401
402
# File 'lib/canis/core/util/basestack.rb', line 393

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


406
407
408
409
410
# File 'lib/canis/core/util/basestack.rb', line 406

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

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



346
347
348
# File 'lib/canis/core/util/basestack.rb', line 346

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

#traverse(c, &block) ⇒ Object

General routin to traverse components and their components



296
297
298
299
300
301
302
303
304
305
306
# File 'lib/canis/core/util/basestack.rb', line 296

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