Class: SyncEnumerator
- Inherits:
-
Array
- Object
- Array
- SyncEnumerator
- Includes:
- Enumerable
- Defined in:
- lib/sync_enumerator.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #end?(i = nil) ⇒ Boolean
-
#initialize(*args) ⇒ SyncEnumerator
constructor
A new instance of SyncEnumerator.
- #inspect ⇒ Object
- #size ⇒ Object (also: #lenght)
Constructor Details
#initialize(*args) ⇒ SyncEnumerator
Returns a new instance of SyncEnumerator.
5 6 7 8 9 10 11 12 13 |
# File 'lib/sync_enumerator.rb', line 5 def initialize(*args) if args.size < 2 raise ArgumentError, "2つ以上のEnumerableオブジェクトを引数として与えて下さい" end i = 0 @enums = args.sort_by {|arg| [arg.size, i += 1]}.reverse @sync_rator = @enums.first.zip(*@enums[1..-1]) p @enums, @sync_rator end |
Instance Method Details
#each(&block) ⇒ Object
15 16 17 |
# File 'lib/sync_enumerator.rb', line 15 def each(&block) @sync_rator.each(&block) end |
#end?(i = nil) ⇒ Boolean
19 20 |
# File 'lib/sync_enumerator.rb', line 19 def end?(i = nil) end |
#inspect ⇒ Object
27 28 29 |
# File 'lib/sync_enumerator.rb', line 27 def inspect "SyncEnumerator: #{@sync_rator}" end |
#size ⇒ Object Also known as: lenght
22 23 24 |
# File 'lib/sync_enumerator.rb', line 22 def size @sync_rator.size end |