Class: ImgToScript::Formatter

Inherits:
Object
  • Object
show all
Includes:
Dry::Configurable
Defined in:
lib/img_to_script/formatter.rb

Overview

Base class.

Formatters format array of target language tokens to an executable script.

A formatter’s responsibility is to label BASIC lines, put separators between the statements’ and their arguments, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#scriptObject (readonly)

Returns the value of attribute script.



14
15
16
# File 'lib/img_to_script/formatter.rb', line 14

def script
  @script
end

Instance Method Details

#format(tokens, **kwargs) ⇒ Array<String>

Format an array of the language tokens to an executable script.

Parameters:

  • tokens (Array<Object>)

    Translator’s output.

  • **kwargs (Hash{ Symbol => Object })

    Options.

Returns:

  • (Array<String>)

    Formatted script.



30
31
32
# File 'lib/img_to_script/formatter.rb', line 30

def format(tokens, **kwargs)
  _format(tokens, **kwargs)
end