Class: Factorix::CLI::Commands::Blueprint::Encode
- Inherits:
-
Factorix::CLI::Commands::Base
- Object
- Dry::CLI::Command
- Factorix::CLI::Commands::Base
- Factorix::CLI::Commands::Blueprint::Encode
- Defined in:
- lib/factorix/cli/commands/blueprint/encode.rb
Overview
Encode JSON to a Factorio blueprint string
Instance Method Summary collapse
-
#call(file: nil, output: nil) ⇒ void
Execute the encode command.
Methods inherited from Factorix::CLI::Commands::Base
backup_support!, confirmable!, inherited, require_game_stopped!
Instance Method Details
#call(file: nil, output: nil) ⇒ void
This method returns an undefined value.
Execute the encode command
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/factorix/cli/commands/blueprint/encode.rb', line 27 def call(file: nil, output: nil, **) json_string = file ? Pathname(file).read : $stdin.read blueprint = Factorix::Blueprint.new(JSON.parse(json_string)) blueprint_string = blueprint.encode if output Pathname(output).write(blueprint_string) else out.print blueprint_string end end |