Class: CooCoo::Transformers::Base

Inherits:
Enumerator show all
Defined in:
lib/coo-coo/transformer.rb

Direct Known Subclasses

Combo, Proxy

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.bin_op(*ops) ⇒ Object



20
21
22
23
24
# File 'lib/coo-coo/transformer.rb', line 20

def self.bin_op(*ops)
  ops.each do |op|
    bin_op_inner(op)
  end
end

.bin_op_inner(op) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/coo-coo/transformer.rb', line 26

def self.bin_op_inner(op)
  define_method(op) do |other|
    Combo.new(self, other) do |a, b|
      a.send(op, b)
    end
  end
end

Instance Method Details

#drop(n) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/coo-coo/transformer.rb', line 6

def drop(n)
  n.times do
    self.next
  end
  
  self
rescue StopIteration
  self
end

#first(n) ⇒ Object



16
17
18
# File 'lib/coo-coo/transformer.rb', line 16

def first(n)
  Stopper.new(self, n)
end