Class: RubyCurses::ModStack::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/rbcurse/core/util/basestack.rb

Overview

A wrapper over widget mostly because it adds weight and margins

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}, widget) ⇒ Item

Returns a new instance of Item.



259
260
261
262
263
264
265
266
267
268
269
# File 'lib/rbcurse/core/util/basestack.rb', line 259

def initialize config={}, widget
  @config = config
  config.each do |k, v|
    instance_variable_set "@#{k}", v
  end
  @margin_left   ||= 0
  @margin_right  ||= 0
  @margin_top    ||= 0
  @margin_bottom ||= 0
  @widget = widget
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



283
284
285
# File 'lib/rbcurse/core/util/basestack.rb', line 283

def method_missing(sym, *args, &block)
  @widget.send sym, *args, &block
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



257
258
259
# File 'lib/rbcurse/core/util/basestack.rb', line 257

def config
  @config
end

#margin_bottomObject (readonly)

Returns the value of attribute margin_bottom.



258
259
260
# File 'lib/rbcurse/core/util/basestack.rb', line 258

def margin_bottom
  @margin_bottom
end

#margin_leftObject (readonly)

Returns the value of attribute margin_left.



258
259
260
# File 'lib/rbcurse/core/util/basestack.rb', line 258

def margin_left
  @margin_left
end

#margin_rightObject (readonly)

Returns the value of attribute margin_right.



258
259
260
# File 'lib/rbcurse/core/util/basestack.rb', line 258

def margin_right
  @margin_right
end

#margin_topObject (readonly)

Returns the value of attribute margin_top.



258
259
260
# File 'lib/rbcurse/core/util/basestack.rb', line 258

def margin_top
  @margin_top
end

#widgetObject (readonly)

Returns the value of attribute widget.



257
258
259
# File 'lib/rbcurse/core/util/basestack.rb', line 257

def widget
  @widget
end

Instance Method Details

#repaintObject



272
# File 'lib/rbcurse/core/util/basestack.rb', line 272

def repaint; @widget.repaint; end

#weightObject



270
# File 'lib/rbcurse/core/util/basestack.rb', line 270

def weight;  @config[:weight]||100; end

#weight=(val) ⇒ Object



271
# File 'lib/rbcurse/core/util/basestack.rb', line 271

def weight=(val); @config[:weight]=val; end