Class: Vedeu::Editor::Delete Private

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/vedeu/editor/delete.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.

Manipulate the lines of an Vedeu::Editor::Document.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, index = nil, size = 0) ⇒ Vedeu::Editor::Delete

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 new instance of Vedeu::Editor::Delete.

Parameters:



27
28
29
30
31
# File 'lib/vedeu/editor/delete.rb', line 27

def initialize(collection, index = nil, size = 0)
  @collection = collection
  @index      = index
  @size       = size
end

Instance Attribute Details

#collectionVedeu::Editor::Line|Vedeu::Editor::Lines (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.



45
46
47
# File 'lib/vedeu/editor/delete.rb', line 45

def collection
  @collection
end

#sizeFixnum (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:

  • (Fixnum)


49
50
51
# File 'lib/vedeu/editor/delete.rb', line 49

def size
  @size
end

Class Method Details

.from(collection, index = nil, size = 0) ⇒ Vedeu::Editor::Line|Vedeu::Editor::Lines

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:



17
18
19
# File 'lib/vedeu/editor/delete.rb', line 17

def self.from(collection, index = nil, size = 0)
  new(collection, index, size).delete
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:

#become(klass, attributes) ⇒ Class 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 one class into another.

Parameters:

  • klass (Class)

    The class to become an instance of.

  • attributes (Hash)

    The attributes of klass.

Returns:

  • (Class)

    Returns a new instance of klass.

#boolean(value) ⇒ 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 the value was a boolean.

Parameters:

  • value (void)

Returns:

#boolean?(value) ⇒ 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 the value is a Boolean.

Parameters:

Returns:

#deleteVedeu::Editor::Line|Vedeu::Editor::Lines

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.



34
35
36
37
38
39
# File 'lib/vedeu/editor/delete.rb', line 34

def delete
  return collection if collection.empty? || negative_index?
  return collection.dup.tap { |c| c.slice!(index) } if index
  return collection.dup.tap(&:pop) if lines?
  return collection.chop if line?
end

#escape?(value) ⇒ 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 the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)

Returns:

#falsy?(value) ⇒ 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 the value should be considered false.

Parameters:

  • value (void)

Returns:

#hash?(value) ⇒ 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 the value is a Hash.

Parameters:

  • value (Hash|void)

Returns:

#indexFixnum (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:

  • (Fixnum)


54
55
56
57
58
59
# File 'lib/vedeu/editor/delete.rb', line 54

def index
  return nil unless @index

  @index = size - 1 if @index > size
  @index
end

#line?Boolean (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.

If true, we are dealing with a Line object.

Returns:



64
65
66
# File 'lib/vedeu/editor/delete.rb', line 64

def line?
  string?(collection)
end

#line_model?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 the model is a Views::Line.

Returns:

#lines?Boolean (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.

If true, we are dealing with a Lines collection.

Returns:



72
73
74
# File 'lib/vedeu/editor/delete.rb', line 72

def lines?
  collection.is_a?(Array)
end

#negative_index?Boolean (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 a boolean indicating whether the index was given or negative.

Returns:



80
81
82
# File 'lib/vedeu/editor/delete.rb', line 80

def negative_index?
  index && index < 0
end

#numeric?(value) ⇒ 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 the value is a Fixnum.

Parameters:

  • value (Fixnum|void)

Returns:

#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:

#snake_case(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.

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"

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

Parameters:

  • klass (Module|Class|String)

Returns:

  • (String)

#stream_model?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 the model is a Views::Stream.

Returns:

#string?(value) ⇒ 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 the value is a Fixnum.

Parameters:

  • value (String|void)

Returns:

#truthy?(value) ⇒ 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 the value should be considered true.

Parameters:

  • value (void)

Returns:

#view_model?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 the model is a Views::View.

Returns: