Sha256: b7b87a9d66354938add8f840acf54bbefea1eed1f50fc30ef6a9cea069882187
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
module Rips module Utils module StringVariableExtension # Check if value is a valid number (...,-1,0,1...) def number? (value) /\A[-]?\d+\z/ === value end # Check if value is between in permitted range def valid_range? (range) if number?(self.slice(1..-1)) self.to_i.between?(range[0], range[1]) else self.slice(1..-1).to_i.between?(range[0], range[1]) end end # Check if value is a valid inmediate (...,-1,0,1...) def inmediate? number?(self) end # Check if value is a register ($0..15) def register? (self[0] == "$") && number?(self.slice(1..-1)) end # Check if value is a port (@0..3) def port? (self[0] == "@") && number?(self.slice(1..-1)) end # Check if value is an address (0..127 | label) def address? (range) (self.is_a?(String)) || (number?(self.slice(1..-1)) && valid_range?(range)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rips-0.1.1 | lib/rips/utils/string_variable.rb |
rips-0.1.0 | lib/rips/utils/string_variable.rb |