Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/searchlink/array.rb
Overview
Array helpers
Instance Method Summary collapse
-
#longest_element ⇒ String
This method takes an array and returns the longest element of that array.
-
#longest_elements ⇒ Array
Finds the longest elements and returns an Array.
-
#shortest_element ⇒ String
Finds the shortest element in an array of strings.
-
#shortest_elements ⇒ Array
Finds the shortest elements in an array of strings.
Instance Method Details
#longest_element ⇒ String
This method takes an array and returns the longest element of that array.
9 10 11 |
# File 'lib/searchlink/array.rb', line 9 def longest_element longest_elements[0] end |
#longest_elements ⇒ Array
Finds the longest elements and returns an Array
16 17 18 |
# File 'lib/searchlink/array.rb', line 16 def longest_elements group_by(&:size).max.last end |
#shortest_element ⇒ String
Finds the shortest element in an array of strings
23 24 25 |
# File 'lib/searchlink/array.rb', line 23 def shortest_element shortest_elements[0] end |
#shortest_elements ⇒ Array
Finds the shortest elements in an array of strings
30 31 32 |
# File 'lib/searchlink/array.rb', line 30 def shortest_elements group_by(&:size).min.last end |