Class: RubyCurses::ModStack::Item

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



263
264
265
266
267
268
269
270
271
272
273
# File 'lib/rbhex/core/util/basestack.rb', line 263

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



287
288
289
# File 'lib/rbhex/core/util/basestack.rb', line 287

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

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



261
262
263
# File 'lib/rbhex/core/util/basestack.rb', line 261

def config
  @config
end

#margin_bottomObject (readonly)

Returns the value of attribute margin_bottom.



262
263
264
# File 'lib/rbhex/core/util/basestack.rb', line 262

def margin_bottom
  @margin_bottom
end

#margin_leftObject (readonly)

Returns the value of attribute margin_left.



262
263
264
# File 'lib/rbhex/core/util/basestack.rb', line 262

def margin_left
  @margin_left
end

#margin_rightObject (readonly)

Returns the value of attribute margin_right.



262
263
264
# File 'lib/rbhex/core/util/basestack.rb', line 262

def margin_right
  @margin_right
end

#margin_topObject (readonly)

Returns the value of attribute margin_top.



262
263
264
# File 'lib/rbhex/core/util/basestack.rb', line 262

def margin_top
  @margin_top
end

#widgetObject (readonly)

Returns the value of attribute widget.



261
262
263
# File 'lib/rbhex/core/util/basestack.rb', line 261

def widget
  @widget
end

Instance Method Details

#repaintObject



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

def repaint; @widget.repaint; end

#weightObject



274
# File 'lib/rbhex/core/util/basestack.rb', line 274

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

#weight=(val) ⇒ Object



275
# File 'lib/rbhex/core/util/basestack.rb', line 275

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