andela-amagana
11/23/2017 - 11:53 AM

Open closed principle fail

# Violation
# This class violates OCP since we would need to modify this class
# when the need arises to support other file formats apart from
# .csv and .xml
class UsageFileParser
  def initialize(client, usage_file)
    @client = client
    @usage_file = uasge_file
  end
  
  def parse
    case  @client.usage_file_format
      when :xml
        parse_xml
      when :csv
        parse_csv
    end
    
    @client.last_parse = Time.now
    @client.save!
  end
  
  private
  
  def parse_xml
    # parse_xml
  end
  
  def parse_csv
    # parse_csv
  end
end