Class: Roast::Cogs::Ruby::Input

Inherits:
Roast::Cog::Input show all
Defined in:
lib/roast/cogs/ruby.rb

Overview

Input specification for the ruby cog

The ruby cog accepts any Ruby value from the input block, which will be directly passed through to the output without modification.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#valueObject

The value to pass through to the output

This value will be directly returned as the ‘value` attribute on the cog’s output object.

: untyped



19
20
21
# File 'lib/roast/cogs/ruby.rb', line 19

def value
  @value
end

Instance Method Details

#coerce(input_return_value) ⇒ Object

Coerce the input from the return value of the input block

The return value from the input block will be used directly as the ‘value` attribute. This allows any Ruby object to be passed through the ruby cog.

#### See Also

  • ‘validate!`

: (untyped) -> void



43
44
45
46
# File 'lib/roast/cogs/ruby.rb', line 43

def coerce(input_return_value)
  super
  @value = input_return_value
end

#validate!Object

Validate that the input has all required parameters

This method ensures that a value has been provided, either directly via the ‘value` attribute or through the input block (via `coerce`).

#### See Also

  • ‘coerce`

: () -> void



30
31
32
# File 'lib/roast/cogs/ruby.rb', line 30

def validate!
  raise Cog::Input::InvalidInputError if value.nil? && !coerce_ran?
end