Class: PrChangelog::CLI::Args
- Inherits:
-
Object
- Object
- PrChangelog::CLI::Args
- Defined in:
- lib/pr_changelog/cli/args.rb
Overview
A simple wrapper over ARGV that is passed to the CLI class
Instance Attribute Summary collapse
-
#raw_args ⇒ Object
readonly
Returns the value of attribute raw_args.
Instance Method Summary collapse
- #include?(flag) ⇒ Boolean
- #include_flags?(flag, flag_variation) ⇒ Boolean
-
#initialize(raw_args) ⇒ Args
constructor
A new instance of Args.
- #last(number) ⇒ Object
- #value_for(flag) ⇒ Object
Constructor Details
#initialize(raw_args) ⇒ Args
Returns a new instance of Args.
7 8 9 |
# File 'lib/pr_changelog/cli/args.rb', line 7 def initialize(raw_args) @raw_args = raw_args end |
Instance Attribute Details
#raw_args ⇒ Object (readonly)
Returns the value of attribute raw_args.
32 33 34 |
# File 'lib/pr_changelog/cli/args.rb', line 32 def raw_args @raw_args end |
Instance Method Details
#include?(flag) ⇒ Boolean
11 12 13 |
# File 'lib/pr_changelog/cli/args.rb', line 11 def include?(flag) raw_args.include?(flag) end |
#include_flags?(flag, flag_variation) ⇒ Boolean
24 25 26 |
# File 'lib/pr_changelog/cli/args.rb', line 24 def include_flags?(flag, flag_variation) include?(flag) || include?(flag_variation) end |
#last(number) ⇒ Object
28 29 30 |
# File 'lib/pr_changelog/cli/args.rb', line 28 def last(number) raw_args.last(number) end |
#value_for(flag) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/pr_changelog/cli/args.rb', line 15 def value_for(flag) return nil unless raw_args.index(flag) next_index = raw_args.index(flag) + 1 value = raw_args.delete_at(next_index) raw_args.delete(flag) value end |