Class: Udb::Instruction::Encoding::Field
- Inherits:
-
Object
- Object
- Udb::Instruction::Encoding::Field
- Defined in:
- lib/udb/obj/instruction.rb
Overview
represents an encoding field (contiguous set of bits that form an opcode or decode variable slot)
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Either string of 0’s and 1’s or a bunch of dashes.
-
#range ⇒ Range
readonly
Range of bits in the parent corresponding to this field.
Instance Method Summary collapse
-
#initialize(name, range) ⇒ Field
constructor
A new instance of Field.
-
#opcode? ⇒ Boolean
Whether or not the field represents part of the opcode (i.e., not a decode variable).
- #to_s ⇒ Object
Constructor Details
#initialize(name, range) ⇒ Field
Returns a new instance of Field.
868 869 870 871 |
# File 'lib/udb/obj/instruction.rb', line 868 def initialize(name, range) @name = name.to_s @range = range end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns Either string of 0’s and 1’s or a bunch of dashes.
861 862 863 |
# File 'lib/udb/obj/instruction.rb', line 861 def name @name end |
#range ⇒ Range (readonly)
Returns Range of bits in the parent corresponding to this field.
864 865 866 |
# File 'lib/udb/obj/instruction.rb', line 864 def range @range end |
Instance Method Details
#opcode? ⇒ Boolean
Returns whether or not the field represents part of the opcode (i.e., not a decode variable).
874 875 876 |
# File 'lib/udb/obj/instruction.rb', line 874 def opcode? name.match?(/^[01]+$/) end |
#to_s ⇒ Object
878 879 880 |
# File 'lib/udb/obj/instruction.rb', line 878 def to_s "#{name}[#{range}]" end |