Class: Setup::Installer::Shebang
- Inherits:
-
Object
- Object
- Setup::Installer::Shebang
- Defined in:
- lib/setup/installer.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cmd, args = []) ⇒ Shebang
constructor
A new instance of Shebang.
- #to_s ⇒ Object
Constructor Details
#initialize(cmd, args = []) ⇒ Shebang
Returns a new instance of Shebang.
347 348 349 350 |
# File 'lib/setup/installer.rb', line 347 def initialize(cmd, args = []) @cmd = cmd @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
353 354 355 |
# File 'lib/setup/installer.rb', line 353 def args @args end |
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
352 353 354 |
# File 'lib/setup/installer.rb', line 352 def cmd @cmd end |
Class Method Details
.load(path) ⇒ Object
333 334 335 336 337 338 339 340 |
# File 'lib/setup/installer.rb', line 333 def Shebang.load(path) line = nil File.open(path) {|f| line = f.gets } return nil unless /\A#!/ =~ line parse(line) end |
.parse(line) ⇒ Object
342 343 344 345 |
# File 'lib/setup/installer.rb', line 342 def Shebang.parse(line) cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ') new(cmd, args) end |
Instance Method Details
#to_s ⇒ Object
355 356 357 |
# File 'lib/setup/installer.rb', line 355 def to_s "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}") end |