Class: HBase::Record
- Inherits:
-
Object
- Object
- HBase::Record
- Defined in:
- lib/hbase/record.rb
Instance Attribute Summary collapse
-
#cells ⇒ Object
readonly
Returns the value of attribute cells.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #get(key) ⇒ Object (also: #[])
-
#initialize ⇒ Record
constructor
A new instance of Record.
- #size ⇒ Object
- #to_hash(with_id = false) ⇒ Object (also: #to_h)
Constructor Details
#initialize ⇒ Record
Returns a new instance of Record.
6 7 8 |
# File 'lib/hbase/record.rb', line 6 def initialize @cells = {} end |
Instance Attribute Details
#cells ⇒ Object (readonly)
Returns the value of attribute cells.
3 4 5 |
# File 'lib/hbase/record.rb', line 3 def cells @cells end |
#id ⇒ Object
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 |
#size ⇒ Object
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 |