Class: SpecTools::Landscape

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

Overview

SpecTools::Landscape

Represents a Spectrum Landscape

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(handle = nil, ssname = nil, precedence = nil, port = nil, service = nil) ⇒ Landscape

Returns a new instance of Landscape.



515
516
517
518
519
520
521
522
523
524
525
# File 'lib/spectools.rb', line 515

def initialize(handle = nil, ssname = nil, precedence = nil, port = nil, service = nil)
  @ss = ssname
  @precedence = precedence
  @port = port
  @service = service
  if handle.nil? || handle.hex?
    @handle = handle
  else
    raise ArgumentError, "Handle is not a hex code"
  end
end

Dynamic Method Handling

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

Instance Attribute Details

#handleObject

The landscape’s handle



513
514
515
# File 'lib/spectools.rb', line 513

def handle
  @handle
end

#portObject

The SS port that the landscape is using



509
510
511
# File 'lib/spectools.rb', line 509

def port
  @port
end

#precedenceObject

The landscape’s precedence



507
508
509
# File 'lib/spectools.rb', line 507

def precedence
  @precedence
end

#serviceObject

The landscape’s service



511
512
513
# File 'lib/spectools.rb', line 511

def service
  @service
end

#ssObject

This landscape’s SpectroSERVER



505
506
507
# File 'lib/spectools.rb', line 505

def ss
  @ss
end

Class Method Details

.cli_get_landscapes(session = nil) ⇒ Object

Use CLI to retrieve all available landscapes.



862
863
864
865
866
867
868
869
870
# File 'lib/vnmsh.rb', line 862

def self.cli_get_landscapes(session=nil)
  session = VNMSH.get_session(session)
  landscapes = Array.new
  lscape_output = session.show_landscapes
  lscape_output.each do |line|
    landscapes.push(Landscape.parse(line))
  end
  return landscapes
end

.cli_parse(line) ⇒ Object

Take a line of CLI show landscapes output and populate a new Landscape object.



855
856
857
858
859
# File 'lib/vnmsh.rb', line 855

def self.cli_parse(line)
  ssname,precedence,port,service,handle = line.chomp.unpack('A33A14A8A12A10')
  landscape = Landscape.new(handle,ssname,precedence,port,service )
  return landscape
end