Class: MinimumSizedHomogeneousArray
- Inherits:
-
HomogeneousArray
- Object
- Array
- HomogeneousArray
- MinimumSizedHomogeneousArray
- Defined in:
- lib/symphony/symphony.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#min_size ⇒ Object
readonly
Returns the value of attribute min_size.
Attributes inherited from HomogeneousArray
Instance Method Summary collapse
- #delete(obj) ⇒ Object
- #delete_at(index) ⇒ Object
-
#initialize(min_size, of_class, *spec) ⇒ MinimumSizedHomogeneousArray
constructor
A new instance of MinimumSizedHomogeneousArray.
Methods inherited from HomogeneousArray
#<<, #==, #[]=, #raise_type_error, #replace
Methods inherited from Array
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_size ⇒ Object (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 |