Class: Toy::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/toy/dev/toy_card.rb

Overview

One step in the algorithm body.

‘kind` discriminates how the renderer formats this step:

"bind"        var ← expr_str                  (numbered)
"update"      var ← expr_str                  (numbered; same as bind, semantically distinct)
"loop_open"   for <expr_str> do               (numbered; indents subsequent steps)
"loop_close"  end for                         (numbered; outdents)
"return"      return var                      (numbered)
"comment"     ▷ note                          (un-numbered; for inline ▷ comments
                                               attached to the previous step)

‘shape` is the right-side annotation (`e ∈ R^T×D` etc.); blank skips it. `note` is an inline ▷ comment appended after the step.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind, var, expr_str, shape, note) ⇒ Step

Returns a new instance of Step.



77
78
79
80
81
82
83
# File 'lib/toy/dev/toy_card.rb', line 77

def initialize(kind, var, expr_str, shape, note)
  @kind     = kind
  @var      = var
  @expr_str = expr_str
  @shape    = shape
  @note     = note
end

Instance Attribute Details

#expr_strObject

Returns the value of attribute expr_str.



75
76
77
# File 'lib/toy/dev/toy_card.rb', line 75

def expr_str
  @expr_str
end

#kindObject

Returns the value of attribute kind.



75
76
77
# File 'lib/toy/dev/toy_card.rb', line 75

def kind
  @kind
end

#noteObject

Returns the value of attribute note.



75
76
77
# File 'lib/toy/dev/toy_card.rb', line 75

def note
  @note
end

#shapeObject

Returns the value of attribute shape.



75
76
77
# File 'lib/toy/dev/toy_card.rb', line 75

def shape
  @shape
end

#varObject

Returns the value of attribute var.



75
76
77
# File 'lib/toy/dev/toy_card.rb', line 75

def var
  @var
end