Class: MinimumSizedHomogeneousArray

Inherits:
HomogeneousArray show all
Defined in:
lib/symphony/symphony.rb

Direct Known Subclasses

AtLeastTwoArray

Instance Attribute Summary collapse

Attributes inherited from HomogeneousArray

#klass

Instance Method Summary collapse

Methods inherited from HomogeneousArray

#<<, #==, #[]=, #raise_type_error, #replace

Methods inherited from Array

#/, #to_homogeneous

Constructor Details

#initialize(min_size, of_class, *spec) ⇒ MinimumSizedHomogeneousArray

Returns a new instance of MinimumSizedHomogeneousArray.



52
53
54
55
56
57
# File 'lib/symphony/symphony.rb', line 52

def initialize(min_size, of_class, *spec)
  raise_size_error(spec.last.size, min_size) if spec.last.size < min_size
  
  super(of_class, *spec)
  @min_size = min_size
end

Instance Attribute Details

#min_sizeObject (readonly)

Returns the value of attribute min_size.



50
51
52
# File 'lib/symphony/symphony.rb', line 50

def min_size
  @min_size
end

Instance Method Details

#delete(obj) ⇒ Object



59
60
61
62
# File 'lib/symphony/symphony.rb', line 59

def delete(obj)
  raise_size_error(self.size - 1, self.min_size) if self.size - 1 < self.min_size
  super(obj)
end

#delete_at(index) ⇒ Object



64
65
66
67
# File 'lib/symphony/symphony.rb', line 64

def delete_at(index)
  raise_size_error(self.size - 1, self.min_size) if self.size - 1 < self.min_size
  super(index)
end