Module: Fairy::TopNIntoRomaInterface

Defined in:
lib/fairy/client/top_n_into_roma.rb

Instance Method Summary collapse

Instance Method Details

#top_n_into_roma(ap, key, n, sep = ',') ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fairy/client/top_n_into_roma.rb', line 10

def top_n_into_roma(ap, key, n, sep=',')
  ap = [ap] if ap.kind_of?(String)

  buf = []
  cnt = 0
  if Config::CONFIG['RUBY_INSTALL_NAME'] =~ /jruby/
    here.each{|s|
      cnt += 1
      buf << s if cnt <= n
    }
  else
    here.each{|s|
      cnt += 1
      buf << s
      break if cnt == n
    }
  end
  roma = Roma::Client::RomaClient.new(ap)
  roma[key] = buf.join(sep)
end