Class: WR::ModListItems::Item
- Inherits:
-
String
- Object
- String
- WR::ModListItems::Item
- Defined in:
- lib/wrb/listcommon.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#target ⇒ Object
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
- #data=(arg) ⇒ Object
- #delete ⇒ Object
-
#initialize(target, idx, str) ⇒ Item
constructor
A new instance of Item.
- #text ⇒ Object
- #text=(str) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(target, idx, str) ⇒ Item
Returns a new instance of Item.
14 15 16 17 18 |
# File 'lib/wrb/listcommon.rb', line 14 def initialize(target, idx, str) @target = target @index = idx super(str.to_s) end |
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
10 11 12 |
# File 'lib/wrb/listcommon.rb', line 10 def index @index end |
#target ⇒ Object
Returns the value of attribute target.
10 11 12 |
# File 'lib/wrb/listcommon.rb', line 10 def target @target end |
Class Method Details
.[](*args) ⇒ Object
12 |
# File 'lib/wrb/listcommon.rb', line 12 def self.[](*args) self.new(*args); end |
Instance Method Details
#data ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/wrb/listcommon.rb', line 27 def data() if @target && @target.alive? dat = @target.send(:_getitemdata, @index, 0) ObjectSpace._id2ref(dat) else @data end end |
#data=(arg) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/wrb/listcommon.rb', line 20 def data=(arg) @data = arg if @target && @target.alive? oid = @data.__id__ @target.send(:_setitemdata, @index, oid) end end |
#delete ⇒ Object
44 45 46 |
# File 'lib/wrb/listcommon.rb', line 44 def delete() @target.delete(@index) end |
#text ⇒ Object
36 37 38 |
# File 'lib/wrb/listcommon.rb', line 36 def text() self.to_s end |
#text=(str) ⇒ Object
40 41 42 |
# File 'lib/wrb/listcommon.rb', line 40 def text=(str) @target[@index] = str.to_s end |
#to_a ⇒ Object
48 |
# File 'lib/wrb/listcommon.rb', line 48 def to_a() [self, self.data]; end |