Class: AttributeStats::AttributeInfo
- Inherits:
-
Object
- Object
- AttributeStats::AttributeInfo
- Defined in:
- lib/entities/attribute_info.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#empty ⇒ Object
readonly
Returns the value of attribute empty.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#references ⇒ Object
readonly
Returns the value of attribute references.
-
#usage_percent ⇒ Object
readonly
Returns the value of attribute usage_percent.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(attribute_name) ⇒ AttributeInfo
constructor
A new instance of AttributeInfo.
- #set_emptyness(is_empty) ⇒ Object
- #set_reference(reference_type, count) ⇒ Object
- #set_usage(record_count, table_total_record_count) ⇒ Object
- #total_references ⇒ Object
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
#count ⇒ Object (readonly)
Returns the value of attribute count.
3 4 5 |
# File 'lib/entities/attribute_info.rb', line 3 def count @count end |
#empty ⇒ Object (readonly)
Returns the value of attribute empty.
3 4 5 |
# File 'lib/entities/attribute_info.rb', line 3 def empty @empty end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/entities/attribute_info.rb', line 3 def name @name end |
#references ⇒ Object (readonly)
Returns the value of attribute references.
3 4 5 |
# File 'lib/entities/attribute_info.rb', line 3 def references @references end |
#usage_percent ⇒ Object (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
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_references ⇒ Object
28 29 30 |
# File 'lib/entities/attribute_info.rb', line 28 def total_references references.values.sum end |