Class: SpecTools::Rule

Inherits:
Object
  • Object
show all
Extended by:
SpecToolsExtensions
Includes:
SpecToolsExtensions
Defined in:
lib/spectools.rb,
lib/vnmsh.rb

Overview

SpecTools::Rule

Represents a Spectrum Rule

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SpecToolsExtensions

call_default_extension, call_extension, method_missing, method_missing

Constructor Details

#initialize(left_mtype = MType.new, right_mtype = MType.new, landscape = Landscape.new) ⇒ Rule

Returns a new instance of Rule.



575
576
577
578
579
# File 'lib/spectools.rb', line 575

def initialize(left_mtype = MType.new, right_mtype = MType.new, landscape = Landscape.new)
  @left_mtype = left_mtype
  @right_mtype = right_mtype
  @landscape = landscape
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SpecToolsExtensions

Instance Attribute Details

#landscapeObject

The landscape on which the Rule exists.



573
574
575
# File 'lib/spectools.rb', line 573

def landscape
  @landscape
end

#left_mtypeObject

The MType on the left hand side of the rule



569
570
571
# File 'lib/spectools.rb', line 569

def left_mtype
  @left_mtype
end

#right_mtypeObject

The MType on the right hand side of the rule



571
572
573
# File 'lib/spectools.rb', line 571

def right_mtype
  @right_mtype
end

Class Method Details

.cli_parse(line) ⇒ Object

Take a line of CLI show rules output and populate a new Rule object.



822
823
824
825
826
827
828
829
830
831
832
833
# File 'lib/vnmsh.rb', line 822

def self.cli_parse(line)
  line.chomp =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+).*$/
  #lmthandle,lmtname,rmthandle,rmtname = line.chomp.unpack('A12A18A12A18')
  lmthandle = $1
  lmtname = $2
  rmthandle = $3
  rmtname = $4
  lmtype = MType.new(lmthandle,lmtname)
  rmtype = MType.new(rmthandle,rmtname)
  rule = Rule.new(lmtype,rmtype)
  return rule
end