Class SSHMenu::HostItem
In: lib/sshmenu.rb  (Git)
Parent: Item

The SSHMenu::HostItem is used as a container for the configuration options associated with a host item on the main menu.

Accessors are provided for the following properties (corresponding to input elements in the ‘Edit Host’ dialog):

  • title
  • sshparams
  • geometry
  • enable_bcvi

Inherits from SSHMenu::Item.

Methods

Public Class methods

Defines a list of attribute names for which accessor methods are generated

[Source]

# File lib/sshmenu.rb, line 1621
    def HostItem.attributes
      [ :title, :sshparams, :geometry, :enable_bcvi ]
    end

Generates accessor methods

[Source]

# File lib/sshmenu.rb, line 1627
    def HostItem.make_accessors
      self.attributes.each { |a| attr(a, true) }
    end

Typically called from SSHMenu::Item#new_from_hash. Retains a copy of the whole attributes hash, allowing unrecognised attributes from the config file to be retained.

[Source]

# File lib/sshmenu.rb, line 1641
    def initialize(h={})
      @type = 'host'
      @hash = h.dup
      self.class.attributes.each { |a| self.send("#{a}=", h[a] || h[a.to_s]) }
    end

Public Instance methods

Returns a deep copy of the current host item.

[Source]

# File lib/sshmenu.rb, line 1649
    def dup
      self.class.new(to_h)
    end

Returns the initial part of the ‘sshparams’ property which defines environment settings - may be an empty string.

[Source]

# File lib/sshmenu.rb, line 1667
    def env_settings
      return sshparams =~ /^((?:\w+="(?:\\"|[^"])*" +)*)/ ? $1 : ''
    end

Returns the ‘sshparams’ property without the initial environment settings section.

[Source]

# File lib/sshmenu.rb, line 1674
    def sshparams_noenv
      return sshparams =~ /^(?:\w+="(?:\\"|[^"])*" +)*(.*)$/ ? $1 : ''
    end

Serialises the host item to a hash (including keys for any unknown attributes which were read in from the config file).

[Source]

# File lib/sshmenu.rb, line 1656
    def to_h
      h = @hash
      h['type'] = 'host'
      self.class.attributes.each { |a| h[a.to_s] = self.send(a) }
      h.delete('enable_bcvi') unless enable_bcvi
      return h
    end

[Validate]