Class: Vedeu::Interfaces::Interface

Inherits:
Object
  • Object
show all
Includes:
Presentation, Repositories::Model, Toggleable
Defined in:
lib/vedeu/interfaces/interface.rb,
lib/vedeu/interfaces/repository.rb

Overview

Interfaces

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Vedeu::Interfaces::Interface

Return a new instance of Vedeu::Interfaces::Interface.

Parameters:

  • attributes (Hash) (defaults to: {})

Options Hash (attributes):



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

def initialize(attributes = {})
  @attributes = defaults.merge!(attributes)

  @attributes.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#attributesHash (readonly)

Returns:

  • (Hash)


16
17
18
# File 'lib/vedeu/interfaces/interface.rb', line 16

def attributes
  @attributes
end

#clientFixnum|Float

Returns:

  • (Fixnum|Float)


20
21
22
# File 'lib/vedeu/interfaces/interface.rb', line 20

def client
  @client
end

#delayFixnum|Float

Returns:

  • (Fixnum|Float)


24
25
26
# File 'lib/vedeu/interfaces/interface.rb', line 24

def delay
  @delay
end

#groupSymbol|String

Returns:

  • (Symbol|String)


28
29
30
# File 'lib/vedeu/interfaces/interface.rb', line 28

def group
  @group
end

#nameString

Returns:

  • (String)


32
33
34
# File 'lib/vedeu/interfaces/interface.rb', line 32

def name
  @name
end

#parentVedeu::Views::Composition



36
37
38
# File 'lib/vedeu/interfaces/interface.rb', line 36

def parent
  @parent
end

#repositoryVedeu::Repositories::Repository Originally defined in module Repositories::Model

#visibleBoolean Also known as: visible? Originally defined in module Toggleable

Returns Whether the toggleable is visible.

Returns:

  • (Boolean)

    Whether the toggleable is visible.

#zindexFixnum

Returns:

  • (Fixnum)


40
41
42
# File 'lib/vedeu/interfaces/interface.rb', line 40

def zindex
  @zindex
end

Instance Method Details

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

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

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

  • (Boolean)

#backgroundVedeu::Colours::Background Originally defined in module Presentation::Colour

When the background colour for the model exists, return it, otherwise returns the parent background colour, or an empty Vedeu::Colours::Background.

#background=(value) ⇒ Vedeu::Colours::Background Originally defined in module Presentation::Colour

Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.

#colourVedeu::Colours::Colour Originally defined in module Presentation::Colour

#colour=(value) ⇒ Vedeu::Colours::Colour Originally defined in module Presentation::Colour

Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.

#defaultsHash (private)

The default values for a new instance of this class.

Returns:

  • (Hash)


108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/vedeu/interfaces/interface.rb', line 108

def defaults
  {
    client:     nil,
    colour:     Vedeu::Colours::Colour.coerce(background: :default,
                                              foreground: :default),
    delay:      0.0,
    group:      '',
    name:       '',
    parent:     nil,
    repository: Vedeu.interfaces,
    style:      :normal,
    visible:    true,
    zindex:     0,
  }
end

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

Removes the module part from the expression in the string.

Examples:

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

Parameters:

  • klass (Class|String)

Returns:

  • (String)

#deputy(client = nil) ⇒ void Originally defined in module Repositories::Model

This method returns an undefined value.

Returns a DSL instance responsible for defining the DSL methods of this model.

Parameters:

  • client (Object|NilClass) (defaults to: nil)

    The client binding represents the client application object that is currently invoking a DSL method. It is required so that we can send messages to the client application object should we need to.

#dsl_classString (private) Originally defined in module Repositories::Model

Returns the DSL class name responsible for this model.

Returns:

  • (String)

#foregroundVedeu::Colours::Foreground Originally defined in module Presentation::Colour

When the foreground colour for the model exists, return it, otherwise returns the parent foreground colour, or an empty Vedeu::Colours::Foreground.

#foreground=(value) ⇒ Vedeu::Colours::Foreground Originally defined in module Presentation::Colour

Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.

#hidevoid

This method returns an undefined value.

Hide the named interface.

Will hide the named interface. If the interface is currently visible, it will be cleared- rendered blank. To show the interface, the ‘:show_interface’ event should be triggered. Triggering the ‘:hide_group’ event to which this named interface belongs will also hide the interface.

Examples:

Vedeu.trigger(:_hide_interface_, name)
Vedeu.hide_interface(name)


77
78
79
80
81
# File 'lib/vedeu/interfaces/interface.rb', line 77

def hide
  super

  Vedeu.trigger(:_clear_view_, name)
end

#position?Boolean (private) Originally defined in module Presentation

Returns a boolean indicating the model has a position attribute.

Returns:

  • (Boolean)

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

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

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

  • (Boolean)

#render_colourString (private) Originally defined in module Presentation

Renders the colour attributes of the receiver and yields (to then render the styles).

Returns:

  • (String)

#render_positionString (private) Originally defined in module Presentation

Returns:

  • (String)

#render_styleString (private) Originally defined in module Presentation

Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).

Returns:

  • (String)

#showvoid

This method returns an undefined value.

Show the named interface.

Will show the named interface. If the interface is currently visible, it will be refreshed- showing any new content available. To hide the interface, the ‘:hide_interface’ event should be triggered. Triggering the ‘:show_group’ event to which this named interface belongs will also show the interface.

Examples:

Vedeu.trigger(:_show_interface_, name)
Vedeu.show_interface(name)


97
98
99
100
101
# File 'lib/vedeu/interfaces/interface.rb', line 97

def show
  super

  Vedeu.trigger(:_refresh_view_, name)
end

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

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)

#storevoid Originally defined in module Repositories::Model

TODO:

Perhaps some validation could be added here?

Note:

If a block is given, store the model, return the model after yielding.

This method returns an undefined value.

Returns The model instance stored in the repository.

#styleVedeu::Presentation::Style Originally defined in module Presentation::Styles

When the style for the model exists, return it, otherwise returns the parent style, or an empty Vedeu::Presentation::Style.

#style=(value) ⇒ Vedeu::Presentation::Style Originally defined in module Presentation::Styles

Allows the setting of the style by coercing the given value into a Vedeu::Presentation::Style.

#to_sString Also known as: to_str Originally defined in module Presentation

Converts the colours and styles to escape sequences, and when the parent model has previously set the colour and style, reverts back to that for consistent formatting.

Returns:

  • (String)

    An escape sequence with value interpolated.

#toggleFalseClass|TrueClass Originally defined in module Toggleable

Toggle the visible state and store the model. When the model is hidden, then it is shown, and vice versa.

Returns:

  • (FalseClass|TrueClass)