Class: Vedeu::Interface

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
DisplayBuffer, Model, Presentation
Defined in:
lib/vedeu/models/interface.rb

Overview

An Interface represents a portion of the terminal defined by Geometry. It is a container for Line and Stream objects.

Instance Attribute Summary collapse

Attributes included from Model

#repository

Instance Method Summary collapse

Methods included from DisplayBuffer

#store_cursor, #store_deferred, #store_focusable, #store_group, #store_immediate, #store_new_buffer

Methods included from Common

#defined_value?

Methods included from Presentation

#_colour, #_style, #background, #background=, #colour, #colour=, #foreground, #foreground=, #parent_background, #parent_colour, #parent_foreground, #parent_style, #render_colour, #render_position, #render_style, #style, #style=, #to_s

Methods included from Model

#demodulize, #deputy, #dsl_class, included

Constructor Details

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

Return a new instance of Vedeu::Interface.

Parameters:

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

Options Hash (attributes):



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/vedeu/models/interface.rb', line 66

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

  @client     = @attributes[:client]
  @delay      = @attributes[:delay]
  @group      = @attributes[:group]
  @lines      = @attributes[:lines]
  @name       = @attributes[:name]
  @parent     = @attributes[:parent]
  @repository = @attributes[:repository]
  @visible    = @attributes[:visible]
end

Instance Attribute Details

#attributesHash (readonly)

Returns:

  • (Hash)


46
47
48
# File 'lib/vedeu/models/interface.rb', line 46

def attributes
  @attributes
end

#clientFixnum|Float

Returns:

  • (Fixnum|Float)


21
22
23
# File 'lib/vedeu/models/interface.rb', line 21

def client
  @client
end

#delayFixnum|Float

Returns:

  • (Fixnum|Float)


25
26
27
# File 'lib/vedeu/models/interface.rb', line 25

def delay
  @delay
end

#groupvoid

This method returns an undefined value.



29
30
31
# File 'lib/vedeu/models/interface.rb', line 29

def group
  @group
end

#linesVedeu::Lines Also known as: content, value

Returns:



86
87
88
# File 'lib/vedeu/models/interface.rb', line 86

def lines
  collection.coerce(@lines, self)
end

#nameString

Returns:

  • (String)


33
34
35
# File 'lib/vedeu/models/interface.rb', line 33

def name
  @name
end

#parentVedeu::Composition

Returns:



37
38
39
# File 'lib/vedeu/models/interface.rb', line 37

def parent
  @parent
end

#visibleBoolean Also known as: visible?

Returns Whether the interface is visible.

Returns:

  • (Boolean)

    Whether the interface is visible.



41
42
43
# File 'lib/vedeu/models/interface.rb', line 41

def visible
  @visible
end

Instance Method Details

#add(child) ⇒ void

This method returns an undefined value.

Parameters:



81
82
83
# File 'lib/vedeu/models/interface.rb', line 81

def add(child)
  @lines = lines.add(child)
end

#cursorObject (private)



134
135
136
# File 'lib/vedeu/models/interface.rb', line 134

def cursor
  @cursor ||= Vedeu.cursors.by_name(name)
end

#defaultsHash (private)

The default values for a new instance of this class.

Returns:

  • (Hash)


141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/vedeu/models/interface.rb', line 141

def defaults
  {
    client:     nil,
    colour:     nil,
    delay:      0.0,
    group:      '',
    lines:      [],
    name:       '',
    parent:     nil,
    repository: Vedeu.interfaces,
    style:      nil,
    visible:    true,
  }
end

#group?Boolean

Returns a boolean indicating whether the interface belongs to a group.

Returns:

  • (Boolean)


105
106
107
# File 'lib/vedeu/models/interface.rb', line 105

def group?
  !group.nil? && !group.empty?
end

#hide_cursorString (private)

Returns:

  • (String)


157
158
159
160
161
# File 'lib/vedeu/models/interface.rb', line 157

def hide_cursor
  return cursor.hide_cursor if cursor.visible?

  ''
end

#lines?Boolean Also known as: content?, value?

Returns a boolean indicating whether the interface has content.

Returns:

  • (Boolean)


95
96
97
# File 'lib/vedeu/models/interface.rb', line 95

def lines?
  lines.any?
end

#renderArray<Array<Vedeu::Char>>

Returns:



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/vedeu/models/interface.rb', line 110

def render
  return [] unless visible?

  [
    hide_cursor,
    Vedeu::Clear.new(self).render,
    Vedeu.borders.by_name(name).render,
    Vedeu::Viewport.render(self),
    show_cursor,
  ]
end

#show_cursorString (private)

Returns:

  • (String)


164
165
166
167
168
# File 'lib/vedeu/models/interface.rb', line 164

def show_cursor
  return cursor.show_cursor if cursor.visible?

  ''
end

#storeInterface

Returns:



123
124
125
126
127
128
129
130
# File 'lib/vedeu/models/interface.rb', line 123

def store
  super

  store_new_buffer
  store_focusable
  store_cursor
  store_group
end