Class: HBase::Response::MetaResponse

Inherits:
BasicResponse show all
Defined in:
lib/hbase/response/meta_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BasicResponse

#parse

Constructor Details

#initialize(raw_data, method) ⇒ MetaResponse

Returns a new instance of MetaResponse.



6
7
8
9
# File 'lib/hbase/response/meta_response.rb', line 6

def initialize(raw_data, method)
  @method = method
  super(raw_data)
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



4
5
6
# File 'lib/hbase/response/meta_response.rb', line 4

def method
  @method
end

Instance Method Details

#parse_content(raw_data) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hbase/response/meta_response.rb', line 11

def parse_content(raw_data)
  case @method
  when :list_tables
    if raw_data.blank?
      puts "There are no available tables in the HBase"
      return []
    end

    doc = REXML::Document.new(raw_data)
    entry = doc.elements["tables"]
    tables = []
    entry.elements.each("table") do |table|
      name = table.elements["name"].text.strip rescue nil
      t = Model::TableDescriptor.new(:name => name)
      tables << t
    end
    tables
  else
      puts "method '#{@method}' not supported yet"
  end
end