Class: RXaal::BoundArray

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
lib/bound_array.rb

Direct Known Subclasses

ShowHide

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ BoundArray

Returns a new instance of BoundArray.



17
18
19
20
# File 'lib/bound_array.rb', line 17

def initialize(klass)
  @bound_class = klass
  @inner_array = Array.new
end

Instance Attribute Details

#bound_classObject (readonly)

Returns the value of attribute bound_class.



9
10
11
# File 'lib/bound_array.rb', line 9

def bound_class
  @bound_class
end

Instance Method Details

#+(other_array) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bound_array.rb', line 34

def +(other_array)
  if (other_array.class == BoundArray && other_array.bound_class == @bound_class)
     new_array = BoundArray.new(@bound_class)
     [@inner_array,other_array.to_a].each {|a|
      a.each {|real|
        new_array << real
      }
     }
     return new_array
  end
  return self
end

#<<(obj) ⇒ Object



22
23
24
25
26
# File 'lib/bound_array.rb', line 22

def <<(obj)
  type_confirmation(obj) {
    return @inner_array << obj
  }
end

#[]=(index, obj) ⇒ Object



28
29
30
31
32
# File 'lib/bound_array.rb', line 28

def []=(index, obj)
  type_confirmation(obj) {
    return @inner_array[index] = obj
  }
end