Class: FpGrowth::PrefixPath
- Inherits:
-
Object
- Object
- FpGrowth::PrefixPath
- Defined in:
- lib/fp_growth/prefix_path.rb
Instance Attribute Summary collapse
-
#support ⇒ Object
readonly
Returns the value of attribute support.
Instance Method Summary collapse
- #+(other) ⇒ Object
-
#<<(arg) ⇒ Object
delegate.
- #==(other) ⇒ Object
-
#each(&block) ⇒ Object
delegate.
-
#initialize(support = 1, array = []) ⇒ PrefixPath
constructor
A new instance of PrefixPath.
-
#size ⇒ Object
delegate.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(support = 1, array = []) ⇒ PrefixPath
Returns a new instance of PrefixPath.
5 6 7 8 |
# File 'lib/fp_growth/prefix_path.rb', line 5 def initialize(support = 1, array = []) @array = array @support = support end |
Instance Attribute Details
#support ⇒ Object (readonly)
Returns the value of attribute support.
3 4 5 |
# File 'lib/fp_growth/prefix_path.rb', line 3 def support @support end |
Instance Method Details
#+(other) ⇒ Object
25 26 27 28 |
# File 'lib/fp_growth/prefix_path.rb', line 25 def +(other) return self unless other FpGrowth::PrefixPath.new([@support, other.support].min, @array + other.to_a) end |
#<<(arg) ⇒ Object
delegate
16 17 18 |
# File 'lib/fp_growth/prefix_path.rb', line 16 def <<(arg) @array << arg end |
#==(other) ⇒ Object
38 39 40 |
# File 'lib/fp_growth/prefix_path.rb', line 38 def ==(other) (support == other.support) && (to_a.content_equal?(other.to_a)) end |
#each(&block) ⇒ Object
delegate
11 12 13 |
# File 'lib/fp_growth/prefix_path.rb', line 11 def each(&block) @array.each(&block) end |
#size ⇒ Object
delegate
21 22 23 |
# File 'lib/fp_growth/prefix_path.rb', line 21 def size @array.size end |
#to_a ⇒ Object
34 35 36 |
# File 'lib/fp_growth/prefix_path.rb', line 34 def to_a @array end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/fp_growth/prefix_path.rb', line 30 def to_s "[#{@array}:#{support}]" end |