Class: Vedeu::Groups::Refresh

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/vedeu/groups/refresh.rb

Overview

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.

Examples:

Vedeu.trigger(:_refresh_group_, group_name)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Vedeu::Groups::Refresh

Return a new instance of Vedeu::Groups::Refresh.

Parameters:

  • name (String|Symbol)


32
33
34
# File 'lib/vedeu/groups/refresh.rb', line 32

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameString|Symbol (readonly, protected)

Returns:

  • (String|Symbol)


49
50
51
# File 'lib/vedeu/groups/refresh.rb', line 49

def name
  @name
end

Class Method Details

.by_name(name) ⇒ Array|Vedeu::Error::ModelNotFound

Returns A collection of the names of interfaces refreshed, or an exception when the group was not found.

Parameters:

  • name (String|Symbol)

    The name of the group to be refreshed.

Returns:

  • (Array|Vedeu::Error::ModelNotFound)

    A collection of the names of interfaces refreshed, or an exception when the group was not found.



24
25
26
# File 'lib/vedeu/groups/refresh.rb', line 24

def self.by_name(name)
  new(name).by_name
end

Instance Method Details

#absent?(variable) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether a variable is nil or empty.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

  • (Boolean)

#by_namevoid

This method returns an undefined value.



37
38
39
40
41
42
43
# File 'lib/vedeu/groups/refresh.rb', line 37

def by_name
  Vedeu.timer("Refresh Group: '#{group_name}'".freeze) do
    Vedeu.groups.by_name(group_name).by_zindex.each do |name|
      Vedeu.trigger(:_refresh_view_, name)
    end
  end
end

#demodulize(klass) ⇒ String Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Removes the module part from the expression in the string.

Examples:

demodulize('Vedeu::SomeModule::SomeClass') # => "SomeClass"

Parameters:

  • klass (Class|String)

Returns:

  • (String)

#group_from_interfaceString|Symbol (private)

Returns:

  • (String|Symbol)


65
66
67
# File 'lib/vedeu/groups/refresh.rb', line 65

def group_from_interface
  @_group_name ||= Vedeu.interfaces.by_name(name).group
end

#group_nameString (private)

Returns:

  • (String)

Raises:



56
57
58
59
60
61
62
# File 'lib/vedeu/groups/refresh.rb', line 56

def group_name
  return name if present?(name)
  return group_from_interface if present?(group_from_interface)

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

#present?(variable) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether a variable has a useful value.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

  • (Boolean)

#snake_case(name) ⇒ String Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts a class name to a lowercase snake case string.

Examples:

snake_case(MyClassName) # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

Parameters:

  • name (String)

Returns:

  • (String)