Class: Bashly::Models::Script

Inherits:
Object
  • Object
show all
Includes:
Renderable
Defined in:
lib/bashly/models/script.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Renderable

#render, #strings

Constructor Details

#initialize(command, function_name = nil) ⇒ Script

Returns a new instance of Script.



8
9
10
# File 'lib/bashly/models/script.rb', line 8

def initialize(command, function_name = nil)
  @command, @function_name = command, function_name
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



6
7
8
# File 'lib/bashly/models/script.rb', line 6

def command
  @command
end

#function_nameObject (readonly)

Returns the value of attribute function_name.



6
7
8
# File 'lib/bashly/models/script.rb', line 6

def function_name
  @function_name
end

Instance Method Details

#codeObject



12
13
14
15
16
17
18
19
20
# File 'lib/bashly/models/script.rb', line 12

def code
  if function_name
    result = [header, render('wrapper')].join "\n"
  else
    result = [header, body].join "\n"
  end

  result.lint
end