Class: Filter

Inherits:
Iterator show all
Defined in:
lib/jiji/util/iterator.rb

Overview

フィルタ

Instance Method Summary collapse

Methods inherited from Iterator

#each

Constructor Details

#initialize(it, &block) ⇒ Filter

Returns a new instance of Filter.



33
34
35
36
37
38
# File 'lib/jiji/util/iterator.rb', line 33

def initialize( it, &block )
  super()
  @it = it
  @test = block
  inner_next
end

Instance Method Details

#closeObject



50
51
52
# File 'lib/jiji/util/iterator.rb', line 50

def close
  @it.close if @it
end

#nextObject



42
43
44
45
46
47
48
49
# File 'lib/jiji/util/iterator.rb', line 42

def next
  raise "illegal state." unless next?
  begin
    return @next_element
  ensure
    inner_next
  end
end

#next?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/jiji/util/iterator.rb', line 39

def next?
  @has_next
end