Class: Stargate::Response::RowResponse
- Inherits:
-
BasicResponse
- Object
- BasicResponse
- Stargate::Response::RowResponse
- Defined in:
- lib/stargate/response/row_response.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Instance Method Summary collapse
-
#initialize(raw_data, method) ⇒ RowResponse
constructor
A new instance of RowResponse.
- #parse_content(raw_data) ⇒ Object
Methods inherited from BasicResponse
Constructor Details
#initialize(raw_data, method) ⇒ RowResponse
Returns a new instance of RowResponse.
6 7 8 9 |
# File 'lib/stargate/response/row_response.rb', line 6 def initialize(raw_data, method) @method = method super(raw_data) end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
4 5 6 |
# File 'lib/stargate/response/row_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 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/stargate/response/row_response.rb', line 11 def parse_content(raw_data) case @method when :show_row doc = JSON.parse(raw_data) rows = doc["Row"] model_rows = [] rows.each do |row| rname = row["key"].strip.unpack("m").first count = row["Cell"].size columns = [] row["Cell"].each do |col| name = col["column"].strip.unpack('m').first value = col["$"].strip.unpack('m').first rescue nil = col["timestamp"].to_i columns << Stargate::Model::Column.new( :name => name, :value => value, :timestamp => ) end model_rows << Stargate::Model::Row.new(:name => rname, :total_count => count, :columns => columns) end model_rows when :create_row verify_success(raw_data) when :delete_row verify_success(raw_data) else puts "method '#{@method}' not supported yet" end end |