Sha256: 9d6f2fd4853e790996d6c74bf672166f73d17c543f56926492e2f45278f42476

Contents?: true

Size: 1.44 KB

Versions: 5

Compression:

Stored size: 1.44 KB

Contents

module Vedeu

  # Refresh an interface, or collection of interfaces belonging to a group.
  #
  # The interfaces will be refreshed in z-index order, meaning that interfaces
  # with a lower z-index will be drawn first. This means overlapping interfaces
  # will be drawn as specified.
  #
  # @example
  #   Vedeu.trigger(:_refresh_group_, group_name)
  #
  class RefreshGroup

    include Vedeu::Common

    # @param name [String] The name of the group to be refreshed.
    # @return [Array|Vedeu::ModelNotFound] A collection of the names of
    #   interfaces refreshed, or an exception when the group was not found.
    def self.by_name(name)
      new(name).by_name
    end

    # Return a new instance of Vedeu::RefreshGroup.
    #
    # @param name [String]
    # @return [Vedeu::RefreshGroup]
    def initialize(name)
      @name = name
    end

    # @return [void]
    def by_name
      Vedeu.timer("Refresh Group: '#{group_name}'") do
        Vedeu.groups.by_name(group_name).by_zindex.each do |name|
          Vedeu::RefreshBuffer.by_name(name)
        end
      end
    end

    protected

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

    private

    # @raise [Vedeu::MissingRequired] When the name is empty or nil.
    # @return [String]
    def group_name
      return name if present?(name)

      fail Vedeu::MissingRequired,
           'Cannot refresh group with an empty group name.'
    end

  end # RefreshGroup

end # Vedeu

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vedeu-0.6.1 lib/vedeu/refresh/refresh_group.rb
vedeu-0.6.0 lib/vedeu/refresh/refresh_group.rb
vedeu-0.5.13 lib/vedeu/refresh/refresh_group.rb
vedeu-0.5.12 lib/vedeu/refresh/refresh_group.rb
vedeu-0.5.11 lib/vedeu/refresh/refresh_group.rb