Class: ExcADG::Payload::Example::Multiplier
- Inherits:
-
Object
- Object
- ExcADG::Payload::Example::Multiplier
- Includes:
- ExcADG::Payload
- Defined in:
- lib/excadg/payload/example.rb
Overview
calculate Nth member of the function y = x(n) * (x(n-1)) where x(0) = 0 and x(1) = 1 it illustrates how payload can be customized with @args and extended by adding methods
Instance Attribute Summary
Attributes included from ExcADG::Payload
Instance Method Summary collapse
Methods included from ExcADG::Payload
Instance Method Details
#get ⇒ Object
64 65 66 |
# File 'lib/excadg/payload/example.rb', line 64 def get -> { get_el x: @args } end |
#get_el(x:) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/excadg/payload/example.rb', line 68 def get_el x: case x when 0 then 0 when 1 then 1 else x * get_el(x: x - 1) end end |