Skip to content

Latest commit

 

History

History
44 lines (28 loc) · 1.37 KB

README.md

File metadata and controls

44 lines (28 loc) · 1.37 KB

Some Ruby Programming Language Notes

About Modules

#include

When we call #include MODULE we're invoking the method Module.append_features(mod) and what it does is to add the constants, methods, and module variables of this module to mod (if this module has not already been added to mod or one of its ancestors.)

You can check one example of it's usage when the FONTS' constant is called on Chip8::Components::Memory that is including Chip8::Components::Fonts

About Reading Files

File#open + String#upack

In this project we need to read the rom from a file...

The following command will open the file form the path passed, set the read mode ('rb' = read binary) and then read it.

File.open(@rom_path, "rb", &:read) #=> "\x00\xE0"

After it, we need to convert the resulted string into a array of binary, and that why we use:

.unpack('C*')

We have 2 instructions as parameters:

  • C => Which is a directive to convert the strings into a 8-bit Unsigned Integer"

  • * => Is to make the array size as big as the data, without empty positions.

More info about File#open and String#unpack