Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/bashly/extensions/array.rb
Instance Method Summary collapse
Instance Method Details
#include_sequence?(*elements) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/bashly/extensions/array.rb', line 17 def include_sequence?(*elements) return false if elements.empty? each_cons(elements.size).any?(elements) end |
#indent(offset) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/bashly/extensions/array.rb', line 4 def indent(offset) return self unless offset.positive? indentation = ' ' * offset indenter = Bashly::IndentationHelper.new indentation map { |line| indenter.indent line } end |
#nonuniq ⇒ Object
13 14 15 |
# File 'lib/bashly/extensions/array.rb', line 13 def nonuniq tally.select { |_key, count| count > 1 }.keys end |