### Home Classes Methods

### In Files

- lib/facets/enumargs.rb

### Methods

- ::wrap_enumerable_method
- #detect
- #find
- #to_a

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Random
- Random::ArrayExtensions
- Random::HashExtensions
- Random::IntegerExtensions
- Random::NumericExtensions
- Random::RangeExtensions
- Random::StringExtensions
- Random::StringExtensions::Self
- FileUtils
- FileUtils::DryRun
- FileUtils::NoWrite
- FileUtils::Verbose
- Digest
- Digest::Class
- Digest::Instance
- Multiton
- Multiton::Inclusive
- Multiton::MetaMethods
- URI
- URI::Hash
- URI::Kernel
- Argvector
- Argvector
- ERB
- ERB::OpenTemplate
- Enumerable
- Enumerable::Arguments
- GetoptLong
- GetoptLong::DSL
- Memoizable
- Memoizable::Copy
- Numeric
- Numeric::Multipliers
- Object
- Object::ArgVector
- Timer
- Timer::Dummy
- Array
- BasicObject
- CGI
- Cloneable
- Continuation
- Date
- DateTime
- Equitable
- File
- Find
- Hash
- Instantiable
- Integer
- Interval
- Kernel
- Math
- Module
- Net
- NilClass
- NullClass
- OpEsc
- OpenStruct
- Pathname
- Platform
- Range
- RbConfig
- Set
- Shellwords
- String
- StringScanner
- Time
- Tuple
- YAML
- Zlib

No matching classes.

# Enumerable::Arguments

### Public Class Methods

wrap_enumerable_method( methodname ) click to toggle source

    # File lib/facets/enumargs.rb, line 50
    def self.wrap_enumerable_method( methodname )

      m = methodname
      meth = Enumerable.instance_method(m)
      arity = meth.arity

      case arity <=> 0
      when 0
        class_eval %{
          def #{m}( *args, &yld )
            enum_for(:each, *args).#{m}( &yld )
          end
        }
      when 1
        class_eval %{
          def #{m}( *args, &yld )
            args, each_args = args[0...#{arity}], args[#{arity}..-1]
            enum_for(:each, *each_args).#{m}( *args, &yld )
          end
        }
      else
        class_eval %{
          def #{m}( *args, &yld )
            enum_for(:each).#{m}( *args, &yld )
          end
        }
      end
    end

### Public Instance Methods

detect(*args, &yld) click to toggle source
Alias for: find
find(*args, &yld) click to toggle source

Make exception for find (a negative arity method) to accept keyword argument.

    ObjectSpace.find(Class, :ifnone=>lambda{1}) { |e| ... }
    ObjectSpace.find(Class, :ifnone=>lambda{1}) { |e| ... }

    # File lib/facets/enumargs.rb, line 94
    def find(*args, &yld)  # future use **keys ?
      if Hash === args.last and args.last.key?(:ifnone)
        ifnone = args.last.delete(:ifnone)
        args.pop if args.last.empty?
        enum_for(:each, *args).find( ifnone, &yld )
      else
        enum_for(:each, *args).find( &yld )
      end
    end

Also aliased as: detect
to_a(*args) click to toggle source

    # File lib/facets/enumargs.rb, line 84
    def to_a(*args)
      map(*args){ |x| x }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.