Class: Rips::Variables::Address
- Defined in:
- lib/rips/variables/address.rb
Instance Attribute Summary collapse
-
#syntax ⇒ Object
readonly
Returns the value of attribute syntax.
Attributes inherited from Variable
Instance Method Summary collapse
-
#initialize(size = 10) ⇒ Address
constructor
@syntax: example syntax @range: bit’s range for variable.
-
#syntax?(value) ⇒ Boolean
Check input variable syntax.
Methods inherited from Variable
#between?, #error, #number?, #port?, #register?, #to_i
Constructor Details
#initialize(size = 10) ⇒ Address
@syntax: example syntax @range: bit’s range for variable
12 13 14 15 16 |
# File 'lib/rips/variables/address.rb', line 12 def initialize(size = 10) super(size) @range = [0, 2**@length-1] @syntax = "#{@range[0]}..#{@range[1]} | label" end |
Instance Attribute Details
#syntax ⇒ Object (readonly)
Returns the value of attribute syntax.
8 9 10 |
# File 'lib/rips/variables/address.rb', line 8 def syntax @syntax end |
Instance Method Details
#syntax?(value) ⇒ Boolean
Check input variable syntax
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rips/variables/address.rb', line 19 def syntax? (value) if (number?(value)) && (between?(value, @range)) true elsif value.is_a?(String) true else false end end |