extensions.rb 507 B

1234567891011121314151617181920212223
  1. require 'hike/normalized_array'
  2. module Hike
  3. # `Extensions` is an internal collection for tracking extension names.
  4. class Extensions < NormalizedArray
  5. # Extensions added to this array are normalized with a leading
  6. # `.`.
  7. #
  8. # extensions << "js"
  9. # extensions << ".css"
  10. #
  11. # extensions
  12. # # => [".js", ".css"]
  13. #
  14. def normalize_element(extension)
  15. if extension[/^\./]
  16. extension
  17. else
  18. ".#{extension}"
  19. end
  20. end
  21. end
  22. end