Class: Groonga::Client::Request::ValuesParameter

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

Instance Method Summary collapse

Constructor Details

#initialize(names, values) ⇒ ValuesParameter

Returns a new instance of ValuesParameter.



129
130
131
132
# File 'lib/groonga/client/request/generic.rb', line 129

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

Instance Method Details

#to_parametersObject



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/groonga/client/request/generic.rb', line 134

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