Sha256: eeb042acc0e0deb3bb0022eaa2897bfab384a19c6828e80625434028b1350495
Contents?: true
Size: 916 Bytes
Versions: 5
Compression:
Stored size: 916 Bytes
Contents
module Ru class Iterator class << self 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 end def initialize(array) @array = array end def to_a Ru::Array.new(@array) end def to_dotsch_output to_a.join("\n") end private def method_missing(method, *args, &block) map_method(method, *args, &block) end def map_method(method, *args, &block) @array.map! { |item| item.send(method, *args, &block) } self end redefined_methods.each do |method| define_method(method) do |*args| map_method(method, *args) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
ru-0.1.2 | lib/ru/iterator.rb |
ru-0.1.1 | lib/ru/iterator.rb |
ru-0.1.0 | lib/ru/iterator.rb |
ru-0.0.3 | lib/ru/iterator.rb |
ru-0.0.2 | lib/ru/iterator.rb |