Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. class Category
  2. include Comparable
  3.  
  4. attr_reader :name
  5.  
  6. ##
  7. # Initialize the Category
  8. #
  9. # +name+ is the name of the current Category
  10. # +context+ is the Liquid:Tag context
  11. #
  12. def initialize(name, context)
  13. @name = name
  14. @context = context
  15. end
  16.  
  17. ##
  18. # Compare this Category against another Category.
  19. # Comparison is a comparison between the 2 names.
  20. #
  21. def <=>(other)
  22. return nil unless name.is_a? String
  23. name <=> other.name
  24. end
  25. end
  26.  
  27. class Categories
  28. ##
  29. # Initialize the list of categories by passing a list of Jekyll::Documents.
  30. #
  31. # +category_names+ A list of strings representing a list of categories.
  32. # +context+ is the Liquid:Tag context
  33. #
  34. def initialize(category_names, context)
  35. category_names = [category_names] unless category_names.is_a? Array
  36. byebug
  37. @category_list = category_names.map{|string| Category.new(string, context)}
  38. end
  39. end
  40.  
  41. (byebug) category_names.map
  42. #<Enumerator: ["Heroku"]:map>
  43. (byebug) Category.new("Heroku", context)
  44. #<Jekyll::Category:0x00000002ee6b80>
  45. (byebug) cat = Category.new("Heroku", context)
  46. #<Jekyll::Category:0x00000002a85000>
  47. (byebug) @category_list = [cat]
  48. *Error in evaluation*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement