Class: Pug::Action::Enumerator
- Inherits:
-
Object
- Object
- Pug::Action::Enumerator
- Defined in:
- lib/pug/action/enumerator.rb
Overview
Formats actions to an enumerated text representation
Instance Method Summary collapse
-
#grouped_names(actions, group_size = 2) ⇒ Array<Array<String>>
Enumerates and groups Action names into a 2D array.
-
#names(actions, show_description = false) ⇒ Array<String>
Enumerates Action names with an optional description.
Instance Method Details
#grouped_names(actions, group_size = 2) ⇒ Array<Array<String>>
Note:
This does not support descriptions at the moment
Enumerates and groups Action names into a 2D array
27 28 29 30 |
# File 'lib/pug/action/enumerator.rb', line 27 def grouped_names(actions, group_size = 2) return [] if group_size <= 0 names(actions).each_slice(group_size).to_a end |
#names(actions, show_description = false) ⇒ Array<String>
Enumerates Action names with an optional description
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pug/action/enumerator.rb', line 11 def names(actions, show_description = false) return [] if actions.nil? actions.each_with_index.map do |action, index| if show_description && !action.description.to_s.empty? "#{index}: #{action.name} # #{action.description}" else "#{index}: #{action.name}" end end end |