Class: SystemRDL::Model::Instance
- Inherits:
-
Object
- Object
- SystemRDL::Model::Instance
- Defined in:
- lib/systemrdl/model/instance.rb
Class Attribute Summary collapse
-
.properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Attribute Summary collapse
-
#instances ⇒ Object
readonly
Returns the value of attribute instances.
-
#layer ⇒ Object
readonly
Returns the value of attribute layer.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#token_range ⇒ Object
readonly
Returns the value of attribute token_range.
Instance Method Summary collapse
- #full_name ⇒ Object
-
#initialize(inst, parent) ⇒ Instance
constructor
A new instance of Instance.
- #pretty_print(pp) ⇒ Object
- #property(property_name) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(inst, parent) ⇒ Instance
Returns a new instance of Instance.
6 7 8 9 10 11 12 13 14 |
# File 'lib/systemrdl/model/instance.rb', line 6 def initialize(inst, parent) @name = inst.element_name @layer = inst.layer @parent = parent @instances = build_sub_instances(inst) @properties = build_properties(inst) @token_range = inst.token_range freeze end |
Class Attribute Details
.properties ⇒ Object (readonly)
Returns the value of attribute properties.
23 24 25 |
# File 'lib/systemrdl/model/instance.rb', line 23 def properties @properties end |
Instance Attribute Details
#instances ⇒ Object (readonly)
Returns the value of attribute instances.
19 20 21 |
# File 'lib/systemrdl/model/instance.rb', line 19 def instances @instances end |
#layer ⇒ Object (readonly)
Returns the value of attribute layer.
17 18 19 |
# File 'lib/systemrdl/model/instance.rb', line 17 def layer @layer end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/systemrdl/model/instance.rb', line 16 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
18 19 20 |
# File 'lib/systemrdl/model/instance.rb', line 18 def parent @parent end |
#token_range ⇒ Object (readonly)
Returns the value of attribute token_range.
20 21 22 |
# File 'lib/systemrdl/model/instance.rb', line 20 def token_range @token_range end |
Instance Method Details
#full_name ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/systemrdl/model/instance.rb', line 47 def full_name elements = [self] current = @parent while current elements.unshift(current) current = current.parent end elements.map(&:name).join('.') end |
#pretty_print(pp) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/systemrdl/model/instance.rb', line 58 def pretty_print(pp) pp.group(2, "#{self} {", '}') do @properties.each_value do |prop_value| pp.breakable pp.pp(prop_value) end @instances.each do |inst| pp.breakable pp.pp(inst) end end end |
#property(property_name) ⇒ Object
71 72 73 |
# File 'lib/systemrdl/model/instance.rb', line 71 def property(property_name) @properties[property_name] end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/systemrdl/model/instance.rb', line 43 def to_s "#{name} (#{layer})" end |