Class: GrnMini::Array
Defined Under Namespace
Classes: IdIsGreaterThanZero
Instance Attribute Summary
Attributes inherited from Table
Instance Method Summary collapse
- #[](id) ⇒ Object
- #add(hash) ⇒ Object (also: #<<)
- #delete(id = nil, &block) ⇒ Object
-
#initialize(name = "Array") ⇒ Array
constructor
A new instance of Array.
Methods inherited from Table
#each, #empty?, #group, #need_setup_columns?, #select, #setup_columns, #size, #sort, #value_type
Constructor Details
#initialize(name = "Array") ⇒ Array
Returns a new instance of Array.
7 8 9 10 11 |
# File 'lib/grn_mini/array.rb', line 7 def initialize(name = "Array") super(name, Groonga[name] || Groonga::Array.create(name: name, persistent: true), ) end |
Instance Method Details
#[](id) ⇒ Object
22 23 24 25 |
# File 'lib/grn_mini/array.rb', line 22 def [](id) raise IdIsGreaterThanZero if id == 0 @grn[id] end |
#add(hash) ⇒ Object Also known as: <<
13 14 15 16 |
# File 'lib/grn_mini/array.rb', line 13 def add(hash) setup_columns(hash) if need_setup_columns? @grn.add(hash) end |
#delete(id = nil, &block) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/grn_mini/array.rb', line 27 def delete(id = nil, &block) if block_given? @grn.delete(&block) else raise IdIsGreaterThanZero if id == 0 @grn.delete(id) end end |