Class: Hackasm::Commands::Asm2Binary
- Inherits:
-
Hackasm::Command
- Object
- Hackasm::Command
- Hackasm::Commands::Asm2Binary
- Defined in:
- lib/hackasm/commands/asm2binary.rb
Constant Summary collapse
- FILE_NAME =
"a.hack".freeze
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(file, options) ⇒ Asm2Binary
constructor
A new instance of Asm2Binary.
Methods inherited from Hackasm::Command
#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which
Constructor Details
#initialize(file, options) ⇒ Asm2Binary
Returns a new instance of Asm2Binary.
11 12 13 14 |
# File 'lib/hackasm/commands/asm2binary.rb', line 11 def initialize(file, ) @file = file @options = end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/hackasm/commands/asm2binary.rb', line 16 def execute(input: $stdin, output: $stdout) assembler_code = File.read(@file) binary = Assembler::Translator.new(assembler_code).translate output.puts binary File.write(FILE_NAME, binary) end |