Class: Brew::Gem::CLI::Arguments
- Inherits:
-
Object
- Object
- Brew::Gem::CLI::Arguments
- Defined in:
- lib/brew/gem/cli.rb
Instance Attribute Summary collapse
-
#ruby_flag ⇒ Object
readonly
Returns the value of attribute ruby_flag.
Instance Method Summary collapse
- #command ⇒ Object
- #flags ⇒ Object
- #gem ⇒ Object
-
#initialize(args) ⇒ Arguments
constructor
A new instance of Arguments.
- #supplied_version ⇒ Object
- #to_brew_args ⇒ Object
- #to_gem_args ⇒ Object
Constructor Details
#initialize(args) ⇒ Arguments
Returns a new instance of Arguments.
25 26 27 28 29 |
# File 'lib/brew/gem/cli.rb', line 25 def initialize(args) @ruby_flag = args.select {|a| RUBY_FLAGS.include?(a) }.last @args = args.reject {|a| RUBY_FLAGS.include?(a) } @args_without_flags = @args.reject {|a| a.start_with?('-') } end |
Instance Attribute Details
#ruby_flag ⇒ Object (readonly)
Returns the value of attribute ruby_flag.
23 24 25 |
# File 'lib/brew/gem/cli.rb', line 23 def ruby_flag @ruby_flag end |
Instance Method Details
#command ⇒ Object
31 32 33 |
# File 'lib/brew/gem/cli.rb', line 31 def command @args_without_flags[0] end |
#flags ⇒ Object
43 44 45 |
# File 'lib/brew/gem/cli.rb', line 43 def flags @flags ||= @args.reject {|a| a == gem || a == supplied_version } end |
#gem ⇒ Object
35 36 37 |
# File 'lib/brew/gem/cli.rb', line 35 def gem @args_without_flags[1] end |
#supplied_version ⇒ Object
39 40 41 |
# File 'lib/brew/gem/cli.rb', line 39 def supplied_version @args_without_flags[2] end |
#to_brew_args ⇒ Object
55 56 57 58 |
# File 'lib/brew/gem/cli.rb', line 55 def to_brew_args stop_index = (flags.index('--') || 0) - 1 flags[0..stop_index] end |
#to_gem_args ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/brew/gem/cli.rb', line 47 def to_gem_args if start = flags.index('--') flags[start..-1] else [] end end |