Class: Conglomerate::Array
- Inherits:
-
Object
- Object
- Conglomerate::Array
- Includes:
- Enumerable
- Defined in:
- lib/conglomerate/array.rb
Instance Method Summary collapse
- #<<(val) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(type) ⇒ Array
constructor
A new instance of Array.
Constructor Details
#initialize(type) ⇒ Array
Returns a new instance of Array.
5 6 7 8 |
# File 'lib/conglomerate/array.rb', line 5 def initialize(type) self.type = type self.storage = [] end |
Instance Method Details
#<<(val) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/conglomerate/array.rb', line 10 def <<(val) if type raise "TypeMismatch" unless val.is_a?(type) end storage << val end |
#each(&block) ⇒ Object
22 23 24 |
# File 'lib/conglomerate/array.rb', line 22 def each(&block) storage.each(&block) end |
#empty? ⇒ Boolean
18 19 20 |
# File 'lib/conglomerate/array.rb', line 18 def empty? storage.empty? end |