Class: Boxybox::Commands::Boxes
- Inherits:
-
Boxybox::Command
- Object
- Boxybox::Command
- Boxybox::Commands::Boxes
- Defined in:
- lib/boxybox/commands/boxes.rb
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(input, options) ⇒ Boxes
constructor
A new instance of Boxes.
Methods inherited from Boxybox::Command
#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which
Constructor Details
#initialize(input, options) ⇒ Boxes
Returns a new instance of Boxes.
9 10 11 12 |
# File 'lib/boxybox/commands/boxes.rb', line 9 def initialize(input, ) @input = input @options = end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/boxybox/commands/boxes.rb', line 14 def execute(input: $stdin, output: $stdout) json_str = @input if @options['file'] file_path = @options['file'] json_str = IO.read(file_path) elsif @options['example'] file_path = "lib/boxybox/templates/boxes/#{@options['example']}.json" json_str = IO.read(file_path) output.puts json_str if @options['print_example'] end boxes = BoxBuilder.create_from_json(json_str) # Command logic goes here ... output.puts boxes end |