Class: Vedeu::Interface

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
DisplayBuffer, Model, Presentation
Defined in:
lib/vedeu/models/view/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?, #to_sentence

Methods included from Presentation

#background, #foreground, #parent_background, #parent_colour, #parent_foreground, #parent_style, #render_border, #render_colour, #render_position, #render_style, #to_s

Methods included from Model

#demodulize, #deputy, #dsl_class, included

Constructor Details

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

Return a new instance of Interface.

Options Hash (attributes):



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/vedeu/models/view/interface.rb', line 59

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

  @colour     = @attributes[:colour]
  @delay      = @attributes[:delay]
  @group      = @attributes[:group]
  @lines      = @attributes[:lines]
  @name       = @attributes[:name]
  @parent     = @attributes[:parent]
  @repository = Vedeu.interfaces
  @style      = @attributes[:style]
end

Instance Attribute Details

#colourObject

Returns the value of attribute colour.



27
28
29
# File 'lib/vedeu/models/view/interface.rb', line 27

def colour
  @colour
end

#delayObject

Returns the value of attribute delay.



27
28
29
# File 'lib/vedeu/models/view/interface.rb', line 27

def delay
  @delay
end

#groupObject

Returns the value of attribute group.



27
28
29
# File 'lib/vedeu/models/view/interface.rb', line 27

def group
  @group
end

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



123
124
125
# File 'lib/vedeu/models/view/interface.rb', line 123

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

#nameObject

Returns the value of attribute name.



27
28
29
# File 'lib/vedeu/models/view/interface.rb', line 27

def name
  @name
end

#parentObject

Returns the value of attribute parent.



27
28
29
# File 'lib/vedeu/models/view/interface.rb', line 27

def parent
  @parent
end

#styleObject

Returns the value of attribute style.



27
28
29
# File 'lib/vedeu/models/view/interface.rb', line 27

def style
  @style
end

Instance Method Details

#add(child) ⇒ void



74
75
76
# File 'lib/vedeu/models/view/interface.rb', line 74

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

#attributesHash

Note:

This may be unused. (GL 2015-02-20)



82
83
84
85
86
87
88
89
90
91
# File 'lib/vedeu/models/view/interface.rb', line 82

def attributes
  {
    colour:   colour,
    delay:    delay,
    group:    group,
    name:     name,
    parent:   parent,
    style:    style,
  }
end

#borderVedeu::Border|NilClass

Returns the border object belonging to the interface.



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

def border
  if border?
    Vedeu.borders.find(name)
  end
end

#border?Boolean

Returns a boolean indicating whether the interface has a border.



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

def border?
  Vedeu.borders.registered?(name)
end

#cursorVedeu::Cursor

Fetch the cursor belonging to this interface (by name), if one does not exist, it will be created, stored and returned.



113
114
115
# File 'lib/vedeu/models/view/interface.rb', line 113

def cursor
  Vedeu.cursors.by_name(name)
end

#defaultsHash (private)

The default values for a new instance of this class.



151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/vedeu/models/view/interface.rb', line 151

def defaults
  {
    client: nil,
    colour: nil,
    delay:  0.0,
    group:  '',
    lines:  [],
    name:   '',
    parent: nil,
    style:  nil,
  }
end

#geometryVedeu::Geometry



118
119
120
# File 'lib/vedeu/models/view/interface.rb', line 118

def geometry
  Vedeu.geometries.find(name)
end

#lines?Boolean

Returns a boolean indicating whether the interface has content.



132
133
134
# File 'lib/vedeu/models/view/interface.rb', line 132

def lines?
  lines.any?
end

#storeInterface



137
138
139
140
141
142
143
144
# File 'lib/vedeu/models/view/interface.rb', line 137

def store
  super

  store_new_buffer
  store_focusable
  store_cursor
  store_group
end