summaryrefslogtreecommitdiff
path: root/lib/slop.rb
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2013-08-13 20:30:39 +0100
committerLee Jarvis <ljjarvis@gmail.com>2013-08-13 20:35:16 +0100
commit0d73ddbc998b0e6124655595639bbbe04c9e456e (patch)
treee224d817a26c5525490080e6b4c56ba28b1ab085 /lib/slop.rb
parent9af8dae80f14ade1b04bd9c36b5ad39e9e039965 (diff)
downloadslop-0d73ddbc998b0e6124655595639bbbe04c9e456e.tar.gz
Use self prefix for class methods over class << self
Diffstat (limited to 'lib/slop.rb')
-rw-r--r--lib/slop.rb51
1 files changed, 24 insertions, 27 deletions
diff --git a/lib/slop.rb b/lib/slop.rb
index 852f1bc..0137b8f 100644
--- a/lib/slop.rb
+++ b/lib/slop.rb
@@ -17,34 +17,31 @@ class Slop
longest_flag: 0
}
- class << self
-
- # items - The Array of items to extract options from (default: ARGV).
- # config - The Hash of configuration options to send to Slop.new().
- # block - An optional block used to add options.
- #
- # Examples:
- #
- # Slop.parse(ARGV, :help => true) do
- # on '-n', '--name', 'Your username', :argument => true
- # end
- #
- # Returns a new instance of Slop.
- def parse(items = ARGV, config = {}, &block)
- parse! items.dup, config, &block
- end
+ # items - The Array of items to extract options from (default: ARGV).
+ # config - The Hash of configuration options to send to Slop.new().
+ # block - An optional block used to add options.
+ #
+ # Examples:
+ #
+ # Slop.parse(ARGV, :help => true) do
+ # on '-n', '--name', 'Your username', :argument => true
+ # end
+ #
+ # Returns a new instance of Slop.
+ def self.parse(items = ARGV, config = {}, &block)
+ parse!(items.dup, config, &block)
+ end
- # items - The Array of items to extract options from (default: ARGV).
- # config - The Hash of configuration options to send to Slop.new().
- # block - An optional block used to add options.
- #
- # Returns a new instance of Slop.
- def parse!(items = ARGV, config = {}, &block)
- config, items = items, ARGV if items.is_a?(Hash) && config.empty?
- slop = new config, &block
- slop.parse! items
- slop
- end
+ # items - The Array of items to extract options from (default: ARGV).
+ # config - The Hash of configuration options to send to Slop.new().
+ # block - An optional block used to add options.
+ #
+ # Returns a new instance of Slop.
+ def self.parse!(items = ARGV, config = {}, &block)
+ config, items = items, ARGV if items.is_a?(Hash) && config.empty?
+ slop = new(config, &block)
+ slop.parse!(items)
+ slop
end
# The Hash of configuration options for this Slop instance.