class EmuPower::Commands::Command
Base class that all commands inherit from
Public Class Methods
new(name)
click to toggle source
# File lib/emu_power/commands.rb, line 10 def initialize(name) @data = { name: name } end
Public Instance Methods
to_command()
click to toggle source
# File lib/emu_power/commands.rb, line 14 def to_command tags = @data.map do |k, v| tag = k.to_s.capitalize next "<#{tag}>#{v}</#{tag}>" end return "<Command>#{tags.join}</Command>" end
to_hex(i, width = 8)
click to toggle source
Convert int to 0xABCD hex
# File lib/emu_power/commands.rb, line 30 def to_hex(i, width = 8) return "0x%0#{width}x" % i end
to_yn(bool)
click to toggle source
Convert bool to Y or N
# File lib/emu_power/commands.rb, line 25 def to_yn(bool) return bool ? 'Y' : 'N' end