Class: DbSpiderNodeSet

Inherits:
Object
  • Object
show all
Defined in:
lib/db_facet/db_spider_node_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDbSpiderNodeSet

Returns a new instance of DbSpiderNodeSet.



4
5
6
7
8
# File 'lib/db_facet/db_spider_node_set.rb', line 4

def initialize
  @set = {}
  @count = 0
  @uniq_count = 0
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



2
3
4
# File 'lib/db_facet/db_spider_node_set.rb', line 2

def count
  @count
end

#uniq_countObject (readonly)

Returns the value of attribute uniq_count.



2
3
4
# File 'lib/db_facet/db_spider_node_set.rb', line 2

def uniq_count
  @uniq_count
end

Instance Method Details

#find_or_create(*args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/db_facet/db_spider_node_set.rb', line 10

def find_or_create *args
  @count += 1
  obj = args[0]
  if node = @set[obj]
    node
  else
    @uniq_count += 1
    @set[obj] = DbSpiderReaderNode.new *args
  end
end