Sha256: 45149cbc2d712d3576f4c5bcf429be40868f018628caaa83bdfb8b0f35af80e6

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'vedeu/output/refresh'

module Vedeu

  # Refreshes the given named group of interfaces.
  #
  # @api private
  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.56 lib/vedeu/output/refresh_group.rb
vedeu-0.4.55 lib/vedeu/output/refresh_group.rb