Class: OpenAPISourceTools::WriteTask

Inherits:
Object
  • Object
show all
Includes:
TaskInterface
Defined in:
lib/openapi/sourcetools/task.rb

Overview

A task that provides contents to be written to a named file. Optionaly the file may be made executable.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TaskInterface

#discard, #system

Constructor Details

#initialize(name, contents, executable = false) ⇒ WriteTask

Returns a new instance of WriteTask.

Raises:

  • (ArgumentError)


97
98
99
100
101
102
# File 'lib/openapi/sourcetools/task.rb', line 97

def initialize(name, contents, executable = false)
  raise ArgumentError, 'name and contents must be given' if name.nil? || contents.nil?
  @name = name
  @contents = contents
  @executable = executable
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



95
96
97
# File 'lib/openapi/sourcetools/task.rb', line 95

def contents
  @contents
end

#executableObject (readonly)

Returns the value of attribute executable.



95
96
97
# File 'lib/openapi/sourcetools/task.rb', line 95

def executable
  @executable
end

#nameObject (readonly)

Returns the value of attribute name.



95
96
97
# File 'lib/openapi/sourcetools/task.rb', line 95

def name
  @name
end

Instance Method Details

#generate(_context_binding) ⇒ Object



104
105
106
# File 'lib/openapi/sourcetools/task.rb', line 104

def generate(_context_binding)
  @contents
end

#output_nameObject



108
109
110
# File 'lib/openapi/sourcetools/task.rb', line 108

def output_name
  @name
end