Class: Groonga::Client::Request::FlagsParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga/client/request/generic.rb

Instance Method Summary collapse

Constructor Details

#initialize(names, flags) ⇒ FlagsParameter

Returns a new instance of FlagsParameter.



158
159
160
161
# File 'lib/groonga/client/request/generic.rb', line 158

def initialize(names, flags)
  @names = names
  @flags = flags
end

Instance Method Details

#to_parametersObject



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/groonga/client/request/generic.rb', line 163

def to_parameters
  case @flags
  when ::Array
    return {} if @flags.empty?
    flags = @flags.collect(&:to_s).join("|")
  when Symbol
    flags = @flags.to_s
  when String
    return {} if /\A\s*\z/ === @flags
    flags = @flags
  when NilClass
    return {}
  else
    flags = @flags
  end
  parameters = {}
  @names.each do |name|
    parameters[name] = flags
  end
  parameters
end