Class: Launchy::Argv

Inherits:
Object
  • Object
show all
Defined in:
lib/launchy/argv.rb

Overview

Internal: Ecapsulate the commandline argumens passed to Launchy

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#argvObject (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

Returns:

  • (Boolean)


29
30
31
# File 'lib/launchy/argv.rb', line 29

def blank?
  @argv.empty? || @argv.first.strip.empty?
end

#executable?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/launchy/argv.rb', line 33

def executable?
  ::Launchy::Application.find_executable(@argv.first)
end

#to_sObject



13
14
15
# File 'lib/launchy/argv.rb', line 13

def to_s
  @argv.join(" ")
end

#to_strObject



17
18
19
# File 'lib/launchy/argv.rb', line 17

def to_str
  to_s
end

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/launchy/argv.rb', line 25

def valid?
  !blank? && executable?
end