Class: Launchy::Argv
- Inherits:
-
Object
- Object
- Launchy::Argv
- Defined in:
- lib/launchy/argv.rb
Overview
Internal: Ecapsulate the commandline argumens passed to Launchy
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](idx) ⇒ Object
- #blank? ⇒ Boolean
- #executable? ⇒ Boolean
-
#initialize(*args) ⇒ Argv
constructor
A new instance of Argv.
- #to_s ⇒ Object
- #to_str ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ Argv
Returns a new instance of Argv.
9 10 11 |
# File 'lib/launchy/argv.rb', line 9 def initialize(*args) @argv = args.flatten end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
7 8 9 |
# File 'lib/launchy/argv.rb', line 7 def argv @argv end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 |
# File 'lib/launchy/argv.rb', line 37 def ==(other) @argv == other.argv end |
#[](idx) ⇒ Object
21 22 23 |
# File 'lib/launchy/argv.rb', line 21 def [](idx) @argv[idx] end |
#blank? ⇒ Boolean
29 30 31 |
# File 'lib/launchy/argv.rb', line 29 def blank? @argv.empty? || @argv.first.strip.empty? end |
#executable? ⇒ Boolean
33 34 35 |
# File 'lib/launchy/argv.rb', line 33 def executable? ::Launchy::Application.find_executable(@argv.first) end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/launchy/argv.rb', line 13 def to_s @argv.join(" ") end |
#to_str ⇒ Object
17 18 19 |
# File 'lib/launchy/argv.rb', line 17 def to_str to_s end |
#valid? ⇒ Boolean
25 26 27 |
# File 'lib/launchy/argv.rb', line 25 def valid? !blank? && executable? end |