Class: Factorix::CLI::Commands::Blueprint::Decode
- Inherits:
-
Factorix::CLI::Commands::Base
- Object
- Dry::CLI::Command
- Factorix::CLI::Commands::Base
- Factorix::CLI::Commands::Blueprint::Decode
- Defined in:
- lib/factorix/cli/commands/blueprint/decode.rb
Overview
Decode a Factorio blueprint string to JSON
Instance Method Summary collapse
-
#call(file: nil, output: nil) ⇒ void
Execute the decode 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 decode command
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/factorix/cli/commands/blueprint/decode.rb', line 25 def call(file: nil, output: nil, **) blueprint_string = file ? Pathname(file).read.strip : $stdin.read.strip blueprint = Factorix::Blueprint.decode(blueprint_string) json_string = blueprint.to_json if output Pathname(output).write(json_string) else out.puts json_string end end |