Class: WxSugar::EnumerableControl::ItemCollection
- Inherits:
-
Object
- Object
- WxSugar::EnumerableControl::ItemCollection
- 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.
Direct Known Subclasses
ItemDataCollection, ListItemTextCollection, StringsCollection
Instance Attribute Summary collapse
-
#cwi ⇒ Object
readonly
Returns the value of attribute cwi.
Instance Method Summary collapse
-
#[](method, i) ⇒ Object
Do a bounds-checked call of some value-fetching method
methdo
for the itemi
. -
#[]=(method, i, val) ⇒ Object
Do a bounds-checked call of some value-setting method
methdo
for the itemi
to valueval
. -
#index?(i) ⇒ Boolean
over-ridden by some subclasses.
-
#initialize(cwi) ⇒ ItemCollection
constructor
A new instance of ItemCollection.
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
#cwi ⇒ Object (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
102 103 104 |
# File 'lib/wx_sugar/enumerable_controls.rb', line 102 def index?(i) i >= 0 and i < cwi.get_count end |