Class: Ruber::OutputWidget::ActionList

Inherits:
Array show all
Defined in:
lib/ruber/output_widget.rb

Overview

Array of actions and separators (represented by nil) which allows to easily

insert an entry before or after another one

Instance Method Summary collapse

Methods inherited from Array

#only?, #sample, #to_array, #to_h

Instance Method Details

#insert_after(entry, *names) ⇒ self

Inserts one or more actions after a given one

Parameters:

  • entry (String, Integer)

    the entry after which the new action(s) should be inserted. If it’s a string, the actions will be inserted after the action with that name. If it’s an integer, the new actions will be inserted after the action at position entry. If the given entry doesn’t exist (or it’s a number larger than the size of the array), the new actions will be appended at the end

  • names (Array<String,nil>)

    the names of the actions to insert. nil entries represent separator

Returns:

  • (self)


1198
1199
1200
# File 'lib/ruber/output_widget.rb', line 1198

def insert_after entry, *names
  insert_after_or_before entry, :after, names
end

#insert_before(entry, *names) ⇒ self

Inserts one or more actions before a given one

Parameters:

  • entry (String, Integer)

    the entry before which the new action(s) should be inserted. If it’s a string, the actions will be inserted before the action with that name. If it’s an integer, the new actions will be inserted before the action at position entry. If the given entry doesn’t exist (or it’s a number larger than the size of the array), the new actions will be appended at the end

  • names (Array<String,nil>)

    the names of the actions to insert. nil entries represent separator

Returns:

  • (self)


1182
1183
1184
# File 'lib/ruber/output_widget.rb', line 1182

def insert_before entry, *names
  insert_after_or_before entry, :before, names
end