Class: Vedeu::Editor::Insert Private

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/vedeu/editor/insert.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, entity, index = nil, size = 0) ⇒ Vedeu::Editor::Insert

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::Insert.



28
29
30
31
32
33
# File 'lib/vedeu/editor/insert.rb', line 28

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

Instance Attribute Details

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



60
61
62
63
64
65
66
67
68
# File 'lib/vedeu/editor/insert.rb', line 60

def collection
  if string?(@collection)
    @collection.dup

  else
    @collection

  end
end

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



46
47
48
# File 'lib/vedeu/editor/insert.rb', line 46

def entity
  @entity
end

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



50
51
52
# File 'lib/vedeu/editor/insert.rb', line 50

def index
  @index
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.



54
55
56
# File 'lib/vedeu/editor/insert.rb', line 54

def size
  @size
end

Class Method Details

.into(collection, entity, index = nil, size = 0) ⇒ String|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.



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

def self.into(collection, entity, index = nil, size = 0)
  new(collection, entity, index, size).insert
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.

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

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

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

#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.)

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

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

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



71
72
73
# File 'lib/vedeu/editor/insert.rb', line 71

def index?
  numeric?(index)
end

#insertString|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.



36
37
38
39
40
# File 'lib/vedeu/editor/insert.rb', line 36

def insert
  return collection.insert(position, entity) if index?

  collection << entity
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.

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

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



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/vedeu/editor/insert.rb', line 76

def position
  if index < 0
    0

  elsif index > size
    size

  else
    index

  end
end

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

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

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

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

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

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