Class: Roadie::Deduplicator
- Inherits:
-
Object
- Object
- Roadie::Deduplicator
- Defined in:
- lib/roadie/deduplicator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(input) ⇒ Deduplicator
constructor
A new instance of Deduplicator.
Constructor Details
#initialize(input) ⇒ Deduplicator
Returns a new instance of Deduplicator.
7 8 9 10 |
# File 'lib/roadie/deduplicator.rb', line 7 def initialize(input) @input = input @duplicates = false end |
Class Method Details
.apply(input) ⇒ Object
3 4 5 |
# File 'lib/roadie/deduplicator.rb', line 3 def self.apply(input) new(input).apply end |
Instance Method Details
#apply ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/roadie/deduplicator.rb', line 12 def apply # Bail early for very small inputs input if input.size < 2 calculate_latest_occurance # Another early bail in case we never even have a duplicate value if has_duplicates? strip_out_duplicates else input end end |