Class: Groonga::Client::Response::ColumnList

Inherits:
Base
  • Object
show all
Includes:
Enumerable
Defined in:
lib/groonga/client/response/column-list.rb

Defined Under Namespace

Classes: Column

Instance Attribute Summary

Attributes inherited from Base

#body, #command, #header, #raw

Instance Method Summary collapse

Methods inherited from Base

#elapsed_time, #error_message, #initialize, parse, #return_code, #start_time, #status_code, #success?

Constructor Details

This class inherits a constructor from Groonga::Client::Response::Base

Instance Method Details

#[](index) ⇒ Object



43
44
45
# File 'lib/groonga/client/response/column-list.rb', line 43

def [](index)
  @columns[index]
end

#body=(body) ⇒ Object



28
29
30
31
# File 'lib/groonga/client/response/column-list.rb', line 28

def body=(body)
  super(body)
  parse_body(body)
end

#eachObject



33
34
35
36
37
# File 'lib/groonga/client/response/column-list.rb', line 33

def each
  @columns.each do |column|
    yield column
  end
end

#parse_body(body) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/groonga/client/response/column-list.rb', line 47

def parse_body(body)
  properties = body.first
  infos = body[1..-1]
  @columns = infos.collect do |info|
    column = Column.new
    properties.each_with_index do |(name, _), i|
      column.send("#{name}=", info[i])
    end
    column
  end
end

#sizeObject



39
40
41
# File 'lib/groonga/client/response/column-list.rb', line 39

def size
  @columns.size
end