Class: AttributeStats::AttributeInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/entities/attribute_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute_name) ⇒ AttributeInfo

Returns a new instance of AttributeInfo.



5
6
7
8
# File 'lib/entities/attribute_info.rb', line 5

def initialize(attribute_name)
  @name = attribute_name
  @references = Hash.new(0)
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



3
4
5
# File 'lib/entities/attribute_info.rb', line 3

def count
  @count
end

#emptyObject (readonly)

Returns the value of attribute empty.



3
4
5
# File 'lib/entities/attribute_info.rb', line 3

def empty
  @empty
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/entities/attribute_info.rb', line 3

def name
  @name
end

#referencesObject (readonly)

Returns the value of attribute references.



3
4
5
# File 'lib/entities/attribute_info.rb', line 3

def references
  @references
end

#usage_percentObject (readonly)

Returns the value of attribute usage_percent.



3
4
5
# File 'lib/entities/attribute_info.rb', line 3

def usage_percent
  @usage_percent
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/entities/attribute_info.rb', line 20

def empty?
  @empty
end

#set_emptyness(is_empty) ⇒ Object



16
17
18
# File 'lib/entities/attribute_info.rb', line 16

def set_emptyness(is_empty)
  @empty = is_empty
end

#set_reference(reference_type, count) ⇒ Object



24
25
26
# File 'lib/entities/attribute_info.rb', line 24

def set_reference(reference_type, count)
  references[reference_type] += count
end

#set_usage(record_count, table_total_record_count) ⇒ Object



10
11
12
13
14
# File 'lib/entities/attribute_info.rb', line 10

def set_usage(record_count, table_total_record_count)
  @count = record_count
  @usage_percent = (record_count / table_total_record_count.to_f).round(5)
  @empty = record_count == 0
end

#total_referencesObject



28
29
30
# File 'lib/entities/attribute_info.rb', line 28

def total_references
  references.values.sum
end