module Enumerable
Public Instance Methods
all_kinds()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 75 def all_kinds map do |a| case a when Kinds a.kinds else a if a.kind_of?(Module) end end.compact.uniq.flatten end
only_kinds_of?(*kinds)
click to toggle source
# File lib/sugar-high/enumerable.rb, line 2 def only_kinds_of? *kinds all?{|a| a.any_kind_of? *kinds } end
only_labels?()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 6 def only_labels? all?{|a| a.kind_of_label? } end
only_numbers?()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 10 def only_numbers? all?{|a| a.kind_of_number? } end
select_kinds_of(*kinds)
click to toggle source
# File lib/sugar-high/enumerable.rb, line 14 def select_kinds_of *kinds select{|a| a.any_kind_of? *kinds } end
select_kinds_of!(*kinds)
click to toggle source
# File lib/sugar-high/enumerable.rb, line 18 def select_kinds_of! *kinds select!{|a| a.any_kind_of? *kinds } self end
select_labels()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 23 def select_labels select{|a| a.kind_of_label? } end
select_labels!()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 36 def select_labels! select!{|a| a.kind_of_label? } self end
select_numbers()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 27 def select_numbers select{|a| a.is_a?(Numeric) } end
select_numbers!()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 31 def select_numbers! select!{|a| a.is_a?(Numeric) } self end
select_only(type)
click to toggle source
# File lib/sugar-high/enumerable.rb, line 64 def select_only type const = type.kind_of_label? ? "#{type.to_s.camelize}".constantize : type select{|a| a.kind_of? const} end
select_only!(type)
click to toggle source
# File lib/sugar-high/enumerable.rb, line 69 def select_only! type const = type.kind_of_label? ? "#{type.to_s.camelize}".constantize : type select!{|a| a.kind_of? const} self end
select_strings()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 55 def select_strings select_only :string end
select_strings!()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 59 def select_strings! select_only! :string self end
select_symbols()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 41 def select_symbols select_only :symbol end
select_symbols!()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 45 def select_symbols! select_only! :symbol self end
select_uniq_symbols!()
click to toggle source
# File lib/sugar-high/enumerable.rb, line 50 def select_uniq_symbols! select_only!(:symbol).uniq! self end