Module: Enumerable

Defined in:
lib/vex/boot/blank.rb,
lib/vex/base/enumerable/deep.rb,
lib/vex/base/enumerable/progress.rb,
lib/vex/base/enumerable/enumerable_ext.rb

Defined Under Namespace

Modules: Etest Classes: ConsoleProgress, Progress

Constant Summary collapse

KEYS =
Deep::KEYS
VALUES =
Deep::VALUES

Instance Method Summary collapse

Instance Method Details

#any_not?(&block) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/vex/base/enumerable/enumerable_ext.rb', line 2

def any_not?(&block)
  not all? { |e| yield(e) }
end

#blank?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/vex/boot/blank.rb', line 20

def blank?
  empty?
end

#camelizeObject



71
72
73
74
75
# File 'lib/vex/base/enumerable/deep.rb', line 71

def camelize
  Deep.map(self, KEYS) do |s|
    s.to_s.camelize
  end
end

#hmap(&block) ⇒ Object



17
18
19
# File 'lib/vex/base/enumerable/enumerable_ext.rb', line 17

def hmap(&block)
  inject({}) { |hash, obj| hash[obj] = yield(obj); hash }
end

#none?(&block) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/vex/base/enumerable/enumerable_ext.rb', line 6

def none?(&block)
  not any? { |e| yield(e) }
end

#reject_blanksObject



65
66
67
68
69
# File 'lib/vex/base/enumerable/deep.rb', line 65

def reject_blanks
  Deep.reject(self, KEYS | VALUES) do |s|
    s.blank?
  end
end

#stable_sort_byObject



10
11
12
13
14
15
# File 'lib/vex/base/enumerable/enumerable_ext.rb', line 10

def stable_sort_by
  # NOTE: if soort_by wouldn't enumerate the array members from
  # the beginning this would fail.
  i=0
  sort_by { |x| [ yield(x), i+=1 ] } 
end

#with_progress(impl = :console) ⇒ Object



59
60
61
# File 'lib/vex/base/enumerable/progress.rb', line 59

def with_progress(impl = :console)
  Progress::IMPLEMENTATIONS[impl].new(self)
end