module Rips::Utils::StringAssemblerExtension
Public Instance Methods
arg_to_i()
click to toggle source
Return integer part of arguments of an instruction
# File lib/rips/utils/string_assembler.rb, line 18 def arg_to_i (/\A[-]?\d+\z/ === self) ? self.to_i : self.slice(1..-1).to_i end
comment?()
click to toggle source
Check if string is a comment
# File lib/rips/utils/string_assembler.rb, line 23 def comment? self[0] == "#" end
del(regexp)
click to toggle source
Delete spaces and tabs
# File lib/rips/utils/string_assembler.rb, line 8 def del(regexp) gsub(regexp,'') end
del!(regexp)
click to toggle source
Delete spaces and tabs
# File lib/rips/utils/string_assembler.rb, line 13 def del!(regexp) gsub!(regexp,'') end
instruction?()
click to toggle source
Check if string is a instruction
# File lib/rips/utils/string_assembler.rb, line 40 def instruction? (!self.empty?) && (self[0] != "#") && (self.scan(/\w+:/).empty?) end
instruction_arguments(instruction)
click to toggle source
Get intruction's arguments of string
# File lib/rips/utils/string_assembler.rb, line 50 def instruction_arguments(instruction) args = self.split("#").first.split("#{instruction} ") args.pop.split("#").first.del(/\s+|\t+/).split(",") unless args.empty? end
instruction_comments()
click to toggle source
Get intruction's comments of string
# File lib/rips/utils/string_assembler.rb, line 56 def instruction_comments self.split("#").slice(1..-1).join end
instruction_name()
click to toggle source
Get intruction's name of string
# File lib/rips/utils/string_assembler.rb, line 45 def instruction_name self.split("#").first.split(" ").first.downcase end
label?(line)
click to toggle source
Check if string is a label
# File lib/rips/utils/string_assembler.rb, line 28 def label?(line) if (!self.empty?) && (self[0] != "#") && (self[-1] == ":") label = self.scan(/\w+:/) if (label.size == 1) return true elsif (label.size > 1) Error::message(8, line+1, self) end end end