Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/ro_thor/array.rb

Instance Method Summary collapse

Instance Method Details

#hits(*args, &blk) ⇒ Object



28
29
30
# File 'lib/ro_thor/array.rb', line 28

def hits(*args, &blk)
  self.flatten.compact.uniq
end

#ro_opts(*args, &blk) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ro_thor/array.rb', line 4

def ro_opts(*args, &blk)
  a = []
  opts = {}

  self.each do |e|
    if e.is_a?(String)
      e.split(" ").each do |_e|
        if _e.match(%r{([^:]+):([^:]+)})
          opts[:"#{$~[1]}"] = $~[2]
        else
          a << _e
        end
      end
    elsif e.is_a?(Hash)
      e.each do |k, v|
        opts[:"#{k}"] = v
      end
    end
  end

  return a, opts
end