Sha256: 71b10fd8630183fdc3fa9f25e5c9aba251a42aec3c97f6152471a58f002989db

Contents?: true

Size: 551 Bytes

Versions: 2

Compression:

Stored size: 551 Bytes

Contents

require "rips/variables/variable"

module Rips
  module Variables
 
    class Port < Variable 

      attr_reader :syntax

      # @syntax: example syntax
      # @range: bit's range for variable
      def initialize(size = 2)
        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.port? && 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/port.rb
rips-0.1.0 lib/rips/variables/port.rb