Class: HBase::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/hbase/record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRecord

Returns a new instance of Record.



6
7
8
# File 'lib/hbase/record.rb', line 6

def initialize
  @cells = {}
end

Instance Attribute Details

#cellsObject (readonly)

Returns the value of attribute cells.



3
4
5
# File 'lib/hbase/record.rb', line 3

def cells
  @cells
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

Instance Method Details

#get(key) ⇒ Object Also known as: []



10
11
12
13
14
15
16
# File 'lib/hbase/record.rb', line 10

def get(key)
  if cell = cells[key]
    cell.value
  else
    nil
  end
end

#sizeObject



19
20
21
# File 'lib/hbase/record.rb', line 19

def size
  cells.size
end

#to_hash(with_id = false) ⇒ Object Also known as: to_h



23
24
25
26
27
28
29
30
# File 'lib/hbase/record.rb', line 23

def to_hash(with_id = false)
  hash = {}
  hash['id'] = id if with_id and id and !id.empty?
  cells.each do |k, v|
    hash[k.sub(/^[^:]*:/, '')] = v.value
  end
  hash
end