You can boil this down to one assertion with an XOR (^)
On Jul 26, 2013 3:08 PM, "Robin Curry" <notifications@github.com> wrote:

> In lib/metric_fu/io.rb:
>
> > +    #   stream = StringIO.new
> > +    #   io_for(stream) do |io|
> > +    #     io.write(output)
> > +    #   end
> > +    #
> > +    # @param path_or_io [String, IO, nil] a file path or an
> > +    # io stream that responds to write. Can be nil. If nil,
> > +    # block is ignored.
> > +    #
> > +    # @yield [IO] an open stream for writing.
> > +    #
> > +    # @note Given a path to a file, an open file will
> > +    # be yielded and closed after the block completes.
> > +    # Given an existing io stream, the stream will not
> > +    # be automatically closed. Cleanup, if necessary, is
> > +    # the responsibility of the caller.
> >      def io_for(path_or_io)
> >        return nil if path_or_io.nil?
>
> Yeah, I think for now I'm leaning toward keeping it simple:
>
> raise ArgumentError, "No path or io provided." if path_or_io.nil?raise ArgumentError, "No block given. Cannot yield io stream." unless block_given?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/metricfu/metric_fu/pull/104/files#r5430499>
> .
>