# File lib/sugar-high/arguments.rb, line 2 def args flatten.map{|a| a.args}.flatten end
# File lib/sugar-high/array.rb, line 106 def extract(sym) map { |e| e.send(sym) } end
Repeat overall-used method here, to use it without Rails
# File lib/sugar-high/array.rb, line 111 def extract_options! last.is_a?(::Hash) ? pop : {} end
# File lib/sugar-high/array.rb, line 77 def file_join File.join(*self.flatten) end
# File lib/sugar-high/file.rb, line 34 def file_names ext = '*' self.map{|a| a.gsub( /(.*)\//, '').gsub(/\.#{Regexp.escape(ext.to_s)}/, '')} end
# File lib/sugar-high/array.rb, line 95 def flat_uniq self.flatten.compact.uniq end
# File lib/sugar-high/array.rb, line 99 def flat_uniq! self.flatten! self.compact! self.uniq! self end
# File lib/sugar-high/regexp.rb, line 24 def grep_it expr return self if !expr self.grep(expr.to_regexp) end
# File lib/sugar-high/arguments.rb, line 12 def last_arg default = {} last = self.flatten.last last.kind_of?(Hash) ? last : default end
# File lib/sugar-high/arguments.rb, line 17 def last_arg_value default = nil last = self.flatten.last raise ArgumentError, "Default value must be a Hash, was #{default}" if !default.kind_of? Hash key = default.keys.first return default[key] if !last.kind_of? Hash last[key] ? last[key] : default[key] end
# File lib/sugar-high/arguments.rb, line 6 def last_option default = self.last_arg last = self.flatten.last last.kind_of?(Hash) ? last : default end
# File lib/sugar-high/array.rb, line 91 def none? self.flatten.compact.empty? end
# File lib/sugar-high/array.rb, line 11 def pick num num.times.inject([]) {|res, x| res << pick_one!} end
# File lib/sugar-high/array.rb, line 6 def pick_one! index = Kernel.rand(self.size) self[index] end
# File lib/sugar-high/array.rb, line 115 def select! &block replace select &block end
# File lib/sugar-high/array.rb, line 60 def to_filenames self.to_strings.map(&:underscore) end
# File lib/sugar-high/array.rb, line 64 def to_filenames! self.to_strings!.map!(&:underscore) end
# File lib/sugar-high/array.rb, line 81 def to_files self.map{|fp| fp.path.to_file } self.extend FilesArray end
# File lib/sugar-high/array.rb, line 86 def to_files! self.map!{|fp| fp.path.to_file } self.extend FilesArray end
# File lib/sugar-high/array.rb, line 68 def to_paths self.map(&:path) end
# File lib/sugar-high/array.rb, line 72 def to_paths! self.map!(&:path) self end
# File lib/sugar-high/array.rb, line 56 def to_strings self.flatten.select_labels.map(&:to_s) end
# File lib/sugar-high/array.rb, line 51 def to_strings! self.flatten! self.select_labels!.map!(&:to_s) end
# File lib/sugar-high/array.rb, line 21 def to_symbols res = self.flatten.select_labels res = res.map{|a| a.to_s.to_sym } if res res || [] end
# File lib/sugar-high/array.rb, line 27 def to_symbols! self.flatten! self.select_labels! self.map!{|a| a.to_s.to_sym } self end
# File lib/sugar-high/array.rb, line 34 def to_symbols_num self.flatten.map{|a| a.kind_of?(Fixnum) ? "_#{a}" : a}.map{|a| a.to_s.to_sym } end
# File lib/sugar-high/array.rb, line 38 def to_symbols_num! self.flatten! self.map!{|a| a.kind_of?(Fixnum) ? "_#{a}" : a}.map!{|a| a.to_s.to_sym } end
# File lib/sugar-high/array.rb, line 43 def to_symbols_uniq to_symbols.uniq end
Generated with the Darkfish Rdoc Generator 2.