Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove superfluous (and erroneous) module includes from IPAddress::IPv6 #15

Closed
wants to merge 1 commit into from

Commits on May 2, 2011

  1. Don't include modules for which the mandatory primitives aren't imple…

    …mented.
    
    IPAddress::IPv6 doesn't implement the *each* method (required for the *Enumerable* module) nor the *<=>* operator (required for the *Comparable* module), so it doesn't make sense to include these modules.
    
    Including these modules makes the IPv6 instances respond to methods like *to_a* (from the *Enumerable* module) and *between?* (from the *Comparable* module), but these methods result in a NoMethodError exception (for the *each* and *<=>* methods respectively).
    
    Example:
    
    irb > IPAddress('::1').to_a
    NoMethodError: undefined method `each' for #<IPAddress::IPv6:0x1016b3990>
    	from (irb):1:in `to_a'
    	from (irb):1
    
    irb > IPAddress('::1').between? 1, 2
    NoMethodError: undefined method `<=>' for #<IPAddress::IPv6:0x1016c5cd0>
    	from (irb):1:in `between?'
    	from (irb):1
    
    
    From the standard Ruby rdoc:
    
    ri Enumerable
    
    The class must provide a method *each*, which yields successive members of the collection. 
    
    ri Comparable
    
    The class must define the *<=>* operator, which compares the receiver against another object
    pvdb committed May 2, 2011
    Copy the full SHA
    7361d75 View commit details
    Browse the repository at this point in the history