Sha256: 3ca76b9c9e2132cc624776f3334332c9a50bf24b956e7bc6b23da9a497207143

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'vedeu/output/refresh'

module Vedeu

  # Refreshes the given named group of interfaces.
  #
  class RefreshGroup

    include Vedeu::Common

    # @param name [String]
    # @return [void]
    def self.by_name(name)
      new(name).by_name
    end

    # @param name [String]
    # @return [Vedeu::RefreshGroup]
    def initialize(name)
      @name = name
    end

    # @return [void]
    def by_name
      zindexed.each { |name| Vedeu::Refresh.by_name(name) }
    end

    protected

    # @!attribute [r] name
    # @return [String]
    attr_reader :name

    private

    # @return [Array<String>]
    def zindexed
      interfaces.sort { |a, b| a.zindex <=> b.zindex }.map(&:name)
    end

    # @return [Array<Vedeu::Interface>]
    def interfaces
      members.map { |name| Vedeu.interfaces.by_name(name) }
    end

    # @return [Set]
    def members
      unless present?(name)
        fail Vedeu::MissingRequired,
             'Cannot refresh group with an empty group name.'
      end

      Vedeu.groups.by_name(name).members
    end

  end # RefreshGroup

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.4.58 lib/vedeu/output/refresh_group.rb
vedeu-0.4.57 lib/vedeu/output/refresh_group.rb