Class: Vedeu::Buffers::View Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable, Repositories::Defaults
Defined in:
lib/vedeu/buffers/view.rb

Overview

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

Allow the creation of individual named buffers for views.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Repositories::Defaults

#initialize, #validate

Methods included from Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Instance Attribute Details

#nameNilClass|Symbol|String (readonly, protected)

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 The name of the model, the target model or the name of the associated model.

Returns:

  • (NilClass|Symbol|String)

    The name of the model, the target model or the name of the associated model.



62
63
64
# File 'lib/vedeu/buffers/view.rb', line 62

def name
  @name
end

Instance Method Details

#attributesHash<Symbol => String|Symbol>

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:

  • (Hash<Symbol => String|Symbol>)


26
27
28
29
30
# File 'lib/vedeu/buffers/view.rb', line 26

def attributes
  {
    name: name,
  }
end

#column(value) ⇒ Fixnum (private)

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.

Parameters:

  • value (void)

Returns:

  • (Fixnum)


68
69
70
# File 'lib/vedeu/buffers/view.rb', line 68

def column(value)
  Vedeu::Point.coerce(value: value.position.x, min: bx, max: bxn).value
end

#currentArray<Vedeu::Cells::Empty> (private)

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:



73
74
75
76
77
78
79
# File 'lib/vedeu/buffers/view.rb', line 73

def current
  @current ||= Vedeu::Buffers::Empty.new(height: bordered_height,
                                         name:   name,
                                         width:  bordered_width,
                                         x:      bx,
                                         y:      by).buffer
end

#defaultsHash<Symbol => void> (private)

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.

The default options/attributes for a new instance of this class.

Returns:

  • (Hash<Symbol => void>)


82
83
84
85
86
# File 'lib/vedeu/buffers/view.rb', line 82

def defaults
  {
    name: nil,
  }
end

#each(&block) ⇒ Enumerator

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.

Provides iteration over the buffer.

Parameters:

  • block (Proc)

Returns:

  • (Enumerator)


36
37
38
# File 'lib/vedeu/buffers/view.rb', line 36

def each(&block)
  current.each(&block)
end

#geometryVedeu::Geometries::Geometry (private)

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 the named geometry from the geometries repository.



89
90
91
# File 'lib/vedeu/buffers/view.rb', line 89

def geometry
  @_geometry ||= Vedeu.geometries.by_name(name)
end

#reset!Vedeu::Buffers::View

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.

Resets the named view buffer back to its empty state.



43
44
45
# File 'lib/vedeu/buffers/view.rb', line 43

def reset!
  Vedeu::Buffers::View.new(attributes)
end

#row(value) ⇒ Fixnum (private)

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.

Parameters:

  • value (void)

Returns:

  • (Fixnum)


95
96
97
# File 'lib/vedeu/buffers/view.rb', line 95

def row(value)
  Vedeu::Point.coerce(value: value.position.y, min: by, max: byn).value
end

#update(value_or_values) ⇒ Vedeu::Buffers::View

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.

Parameters:

Returns:



50
51
52
53
54
55
56
# File 'lib/vedeu/buffers/view.rb', line 50

def update(value_or_values)
  Array(value_or_values).flatten.each do |value|
    write(value) if positionable?(value)
  end

  self
end

#write(value) ⇒ NilClass|void (private)

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.

Write the value into the respective cell as defined by the position attribute.

Parameters:

  • value (void)

Returns:

  • (NilClass|void)


104
105
106
# File 'lib/vedeu/buffers/view.rb', line 104

def write(value)
  current[row(value)][column(value)] = value
end