Class: Insertion
- Inherits:
-
Object
- Object
- Insertion
- Defined in:
- lib/yard/core_ext/insertion.rb
Overview
The Insertion class inserts a value before or after another value in a list.
Instance Method Summary collapse
-
#after(val, recursive = false) ⇒ Object
Inserts the value after
val
. -
#after_any(val) ⇒ Object
Alias for #after with
recursive
set to true. -
#before(val, recursive = false) ⇒ Object
Inserts the value before
val
. -
#before_any(val) ⇒ Object
Alias for #before with
recursive
set to true. -
#initialize(list, value) ⇒ Insertion
constructor
Creates an insertion object on a list with a value to be inserted.
Constructor Details
#initialize(list, value) ⇒ Insertion
14 15 16 17 |
# File 'lib/yard/core_ext/insertion.rb', line 14 def initialize(list, value) @list = list @values = (Array === value ? value : [value]) end |
Instance Method Details
#after(val, recursive = false) ⇒ Object
Inserts the value after val
.
30 |
# File 'lib/yard/core_ext/insertion.rb', line 30 def after(val, recursive = false) insertion(val, 1, recursive) end |
#after_any(val) ⇒ Object
Alias for #after with recursive
set to true
38 |
# File 'lib/yard/core_ext/insertion.rb', line 38 def after_any(val) insertion(val, 1, true) end |
#before(val, recursive = false) ⇒ Object
Inserts the value before val
22 |
# File 'lib/yard/core_ext/insertion.rb', line 22 def before(val, recursive = false) insertion(val, 0, recursive) end |
#before_any(val) ⇒ Object
Alias for #before with recursive
set to true
34 |
# File 'lib/yard/core_ext/insertion.rb', line 34 def before_any(val) insertion(val, 0, true) end |