Module: CommandLion::Raw
- Defined in:
- lib/command_lion/raw.rb
Overview
Raw command-line option API
Class Method Summary collapse
- .arguments ⇒ Object
- .arguments=(args) ⇒ Object
- .arguments? ⇒ Boolean
- .arguments_to(string, flags) ⇒ Object
- .arguments_to?(flag) ⇒ Boolean
- .clear! ⇒ Object
- .index_of(flag) ⇒ Object
- .index_of?(flag) ⇒ Boolean
- .possible_argument_to(string) ⇒ Object
Class Method Details
.arguments ⇒ Object
8 9 10 11 12 13 |
# File 'lib/command_lion/raw.rb', line 8 def self.arguments return @arguments unless block_given? @arguments.each do |argument| yield argument end end |
.arguments=(args) ⇒ Object
15 16 17 |
# File 'lib/command_lion/raw.rb', line 15 def self.arguments=(args) @arguments = args end |
.arguments? ⇒ Boolean
19 20 21 |
# File 'lib/command_lion/raw.rb', line 19 def self.arguments? arguments.size > 0 ? true : false end |
.arguments_to(string, flags) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/command_lion/raw.rb', line 31 def self.arguments_to(string, flags) return if string.nil? return if flags.nil? return unless index = index_of(string) if block_given? arguments.drop(index+1).each do |argument| # next if argument == "," break if flags.include?(argument) yield argument end else args = [] arguments_to(string, flags) { |arg| args << arg } return args end end |
.arguments_to?(flag) ⇒ Boolean
48 49 50 |
# File 'lib/command_lion/raw.rb', line 48 def self.arguments_to?(flag) arguments[arguments.index(flag) + 1] ? true : false end |
.clear! ⇒ Object
56 57 58 |
# File 'lib/command_lion/raw.rb', line 56 def self.clear! @arguments = [] end |
.index_of(flag) ⇒ Object
23 24 25 |
# File 'lib/command_lion/raw.rb', line 23 def self.index_of(flag) arguments.index(flag) end |
.index_of?(flag) ⇒ Boolean
27 28 29 |
# File 'lib/command_lion/raw.rb', line 27 def self.index_of?(flag) index_of(flag) ? true : false end |
.possible_argument_to(string) ⇒ Object
52 53 54 |
# File 'lib/command_lion/raw.rb', line 52 def self.possible_argument_to(string) arguments[arguments.index(string) + 1] end |