Class: Regent::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/regent/tool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, description:) ⇒ Tool

Returns a new instance of Tool.



7
8
9
10
# File 'lib/regent/tool.rb', line 7

def initialize(name:, description:)
  @name = name
  @description = description
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/regent/tool.rb', line 12

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/regent/tool.rb', line 12

def name
  @name
end

Instance Method Details

#call(argument) ⇒ Object

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/regent/tool.rb', line 14

def call(argument)
  raise NotImplementedError, "Tool #{name} has not implemented the execute method"
end

#execute(*arguments) ⇒ Object



18
19
20
21
22
# File 'lib/regent/tool.rb', line 18

def execute(*arguments)
  call(*arguments)
rescue NotImplementedError, StandardError => e
  raise ToolError, e.message
end

#to_sObject



24
25
26
# File 'lib/regent/tool.rb', line 24

def to_s
  "#{name} - #{description}"
end