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.
9 10 11 12 |
# File 'lib/roadie/deduplicator.rb', line 9 def initialize(input) @input = input @duplicates = false end |
Class Method Details
.apply(input) ⇒ Object
5 6 7 |
# File 'lib/roadie/deduplicator.rb', line 5 def self.apply(input) new(input).apply end |
Instance Method Details
#apply ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/roadie/deduplicator.rb', line 14 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 |