Class: WxSugar::EnumerableControl::ItemCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/wx_sugar/enumerable_controls.rb

Overview

These classes provide proxy accessors for items within the control. ItemCollection is an abstract base class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cwi) ⇒ ItemCollection

Returns a new instance of ItemCollection.



79
80
81
# File 'lib/wx_sugar/enumerable_controls.rb', line 79

def initialize(cwi)
  @cwi = cwi
end

Instance Attribute Details

#cwiObject (readonly)

Returns the value of attribute cwi.



78
79
80
# File 'lib/wx_sugar/enumerable_controls.rb', line 78

def cwi
  @cwi
end

Instance Method Details

#[](method, i) ⇒ Object

Do a bounds-checked call of some value-fetching method methdo for the item i



85
86
87
88
89
90
# File 'lib/wx_sugar/enumerable_controls.rb', line 85

def [](method, i)
  unless index?(i)
    raise IndexError, "No such item #{i} in #{self.cwi}"
  end
  cwi.send( method, i )
end

#[]=(method, i, val) ⇒ Object

Do a bounds-checked call of some value-setting method methdo for the item i to value val



94
95
96
97
98
99
# File 'lib/wx_sugar/enumerable_controls.rb', line 94

def []=(method, i, val)
  unless index?(i)
    raise IndexError, "No such item #{i} in #{self.cwi}"
  end
  cwi.send( method, i, val )
end

#index?(i) ⇒ Boolean

over-ridden by some subclasses

Returns:

  • (Boolean)


102
103
104
# File 'lib/wx_sugar/enumerable_controls.rb', line 102

def index?(i)
  i >= 0 and i < cwi.get_count
end