Class: Ru::Iterator

Inherits:
Object
  • Object
show all
Defined in:
lib/ru/iterator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(array) ⇒ Iterator

Returns a new instance of Iterator.



15
16
17
# File 'lib/ru/iterator.rb', line 15

def initialize(array)
  @array = array
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



29
30
31
# File 'lib/ru/iterator.rb', line 29

def method_missing(method, *args, &block)
  map_method(method, *args, &block)
end

Class Method Details

.redefined_methodsObject



4
5
6
7
8
9
10
11
12
# File 'lib/ru/iterator.rb', line 4

def redefined_methods
  @redefined_methods ||= begin 
    preserved_methods = %{initialize method_missing respond_to? to_a}
    [].public_methods.select do |method|
      method = method.to_s
      method =~ /^[a-z]/ && !preserved_methods.include?(method)
    end
  end
end

Instance Method Details

#to_aObject



19
20
21
# File 'lib/ru/iterator.rb', line 19

def to_a
  Ru::Array.new(@array)
end

#to_stdoutObject



23
24
25
# File 'lib/ru/iterator.rb', line 23

def to_stdout
  to_a.join("\n")
end