Sha256: 691438390e7424bd78820f6f70258fbe856278d9cf8e9504187abfefa8abac9b

Contents?: true

Size: 558 Bytes

Versions: 2

Compression:

Stored size: 558 Bytes

Contents

require "rips/variables/variable"

module Rips
  module Variables

    class Register < Variable 

      attr_reader :syntax

      # @syntax: example syntax
      # @range: bit's range for variable
      def initialize(size = 4)
        super(size)
        @range = [0, 2**@length-1]
        @syntax = "$#{@range[0]}-#{@range[1]}"
      end

      # Check input variable syntax
      def valid_syntax? (value)
        value.extend(Rips::Utils::StringVariableExtension)
        value.register? && value.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/variables/register.rb
rips-0.1.0 lib/rips/variables/register.rb