Class: Vedeu::Editor::Item Private
- Inherits:
-
Object
- Object
- Vedeu::Editor::Item
- Defined in:
- lib/vedeu/editor/item.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.
Fetches an item from a collection.
Instance Attribute Summary collapse
- #collection ⇒ Vedeu::Editor::Line|Vedeu::Editor::Lines readonly protected private
- #index ⇒ Fixnum readonly protected private
Class Method Summary collapse
Instance Method Summary collapse
- #by_index ⇒ String|Vedeu::Editor::Line private
-
#initialize(collection, index = nil) ⇒ Vedeu::Editor::item
constructor
private
Returns a new instance of Vedeu::Editor::Item.
-
#size ⇒ Fixnum
private
private
Returns the size of the collection or 0.
Constructor Details
#initialize(collection, index = nil) ⇒ Vedeu::Editor::item
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::Item.
24 25 26 27 |
# File 'lib/vedeu/editor/item.rb', line 24 def initialize(collection, index = nil) @collection = collection @index = index end |
Instance Attribute Details
#collection ⇒ Vedeu::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.
49 50 51 |
# File 'lib/vedeu/editor/item.rb', line 49 def collection @collection end |
#index ⇒ Fixnum (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.
53 54 55 |
# File 'lib/vedeu/editor/item.rb', line 53 def index @index end |
Class Method Details
.by_index(collection, index = nil) ⇒ String|Vedeu::Editor::Line
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.
15 16 17 |
# File 'lib/vedeu/editor/item.rb', line 15 def self.by_index(collection, index = nil) new(collection, index).by_index end |
Instance Method Details
#by_index ⇒ String|Vedeu::Editor::Line
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.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vedeu/editor/item.rb', line 30 def by_index return nil unless size > 0 if index.nil? || index > size collection[-1] elsif index > 0 && index <= size collection[index] else collection[0] end end |
#size ⇒ 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.
Returns the size of the collection or 0.
60 61 62 63 64 65 66 67 68 |
# File 'lib/vedeu/editor/item.rb', line 60 def size if collection collection.size else 0 end end |