Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Return an Enumerator if no block was given to #each

  • Loading branch information...
commit ef926d86716fe554fb3534d05f745c23c3199b85 1 parent 35d288d
@drbrain authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/pasteboard.rb
View
5 lib/pasteboard.rb
@@ -1,4 +1,5 @@
require 'pasteboard/pasteboard'
+require 'enumerator'
##
# Pasteboard wraps the OS X pasteboard (clipboard) allowing you to paste
@@ -66,6 +67,8 @@ def [] index, flavor = nil
# See #[] for a description of an item.
def each flavor = nil # :yields: item
+ return Enumerator.new(self, :each, flavor) unless block_given?
+
flags = sync
raise Error, 'pasteboard sync error' if (flags & MODIFIED) != 0
@@ -94,6 +97,8 @@ def get id, flavor = nil
end
return nil if item.empty?
+
+ item
end
def inspect # :nodoc:
Please sign in to comment.
Something went wrong with that request. Please try again.