Class: SpecTools::Relation
- Inherits:
-
Object
- Object
- SpecTools::Relation
- Extended by:
- SpecToolsExtensions
- Includes:
- SpecToolsExtensions
- Defined in:
- lib/spectools.rb,
lib/vnmsh.rb
Overview
SpecTools::Relation
Represents a Spectrum relation
Instance Attribute Summary collapse
-
#landscape ⇒ Object
The landscape on which the Relation exists.
-
#name ⇒ Object
The relation’s name.
-
#type ⇒ Object
This relation’s type.
Class Method Summary collapse
-
.cli_find(landscape = nil, session = nil) ⇒ Object
Use CLI to locate Reltions.
-
.cli_parse(line) ⇒ Object
Take a line of CLI
show relationsoutput and populate a new Relation object.
Instance Method Summary collapse
-
#cli_associate(left_model, right_model, session = nil) ⇒ Object
Use CLI to create a new Association based on this Relation.
-
#cli_get_rules(landscape = nil, session = nil) ⇒ Object
Retrieve an Array of Rules for the given Relation.
-
#initialize(name = nil, type = nil, landscape = Landscape.new) ⇒ Relation
constructor
A new instance of Relation.
Methods included from SpecToolsExtensions
call_default_extension, call_extension, method_missing, method_missing
Constructor Details
#initialize(name = nil, type = nil, landscape = Landscape.new) ⇒ Relation
Returns a new instance of Relation.
389 390 391 392 393 |
# File 'lib/spectools.rb', line 389 def initialize(name = nil, type = nil, landscape = Landscape.new) @name = name @type = type @landscape = landscape end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SpecToolsExtensions
Instance Attribute Details
#landscape ⇒ Object
The landscape on which the Relation exists.
387 388 389 |
# File 'lib/spectools.rb', line 387 def landscape @landscape end |
#name ⇒ Object
The relation’s name
383 384 385 |
# File 'lib/spectools.rb', line 383 def name @name end |
#type ⇒ Object
This relation’s type
385 386 387 |
# File 'lib/spectools.rb', line 385 def type @type end |
Class Method Details
.cli_find(landscape = nil, session = nil) ⇒ Object
Use CLI to locate Reltions. Returns an array of Relation objects.
If lanscape is set to a Landscape or a landscape handle, will only show relations for the given landscape.
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
# File 'lib/vnmsh.rb', line 539 def self.cli_find(landscape=nil,session=nil) relations = Array.new session = VNMSH.get_session(session) rel_output = session.show_relations(landscape) rel_output.each do |line| relation = Relation.parse(line) if landscape if landscape.kind_of?(Landscape) relation.landscape = landscape else relation.landscape = Landscape.new(landscape) end else relation.landscape = session.current_landscape end relations.push(relation) end return relations end |
.cli_parse(line) ⇒ Object
Take a line of CLI show relations output and populate a new Relation object.
529 530 531 532 533 |
# File 'lib/vnmsh.rb', line 529 def self.cli_parse(line) name,type = line.chomp.unpack('A33A15') rel = Relation.new(name,type) return rel end |
Instance Method Details
#cli_associate(left_model, right_model, session = nil) ⇒ Object
Use CLI to create a new Association based on this Relation. Model arguments may be Model objects or model handles.
586 587 588 589 |
# File 'lib/vnmsh.rb', line 586 def cli_associate(left_model,right_model,session=nil) session = VNMSH.get_session(session) return session.create_association(self,left_model,right_model) end |
#cli_get_rules(landscape = nil, session = nil) ⇒ Object
Retrieve an Array of Rules for the given Relation.
If lanscape is set to a Landscape or a landscape handle, will only show rules for the given landscape.
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
# File 'lib/vnmsh.rb', line 564 def cli_get_rules(landscape=nil,session=nil) session = VNMSH.get_session(session) rules = Array.new rule_output = session.show_rules(self) rule_output.each do |line| rule = Rule.parse(line) if landscape if landscape.kind_of?(Landscape) rule.landscape = landscape else rule.landscape = Landscape.new(landscape) end else rule.landscape = session.current_landscape end rules.push(rule) end return rules end |