Class: RubyCurses::ModStack::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/canis/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.



265
266
267
268
269
270
271
272
273
274
275
# File 'lib/canis/core/util/basestack.rb', line 265

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



289
290
291
# File 'lib/canis/core/util/basestack.rb', line 289

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

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



263
264
265
# File 'lib/canis/core/util/basestack.rb', line 263

def config
  @config
end

#margin_bottomObject (readonly)

Returns the value of attribute margin_bottom.



264
265
266
# File 'lib/canis/core/util/basestack.rb', line 264

def margin_bottom
  @margin_bottom
end

#margin_leftObject (readonly)

Returns the value of attribute margin_left.



264
265
266
# File 'lib/canis/core/util/basestack.rb', line 264

def margin_left
  @margin_left
end

#margin_rightObject (readonly)

Returns the value of attribute margin_right.



264
265
266
# File 'lib/canis/core/util/basestack.rb', line 264

def margin_right
  @margin_right
end

#margin_topObject (readonly)

Returns the value of attribute margin_top.



264
265
266
# File 'lib/canis/core/util/basestack.rb', line 264

def margin_top
  @margin_top
end

#widgetObject (readonly)

Returns the value of attribute widget.



263
264
265
# File 'lib/canis/core/util/basestack.rb', line 263

def widget
  @widget
end

Instance Method Details

#repaintObject



278
# File 'lib/canis/core/util/basestack.rb', line 278

def repaint; @widget.repaint; end

#weightObject



276
# File 'lib/canis/core/util/basestack.rb', line 276

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

#weight=(val) ⇒ Object



277
# File 'lib/canis/core/util/basestack.rb', line 277

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