Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Category
- include Comparable
- attr_reader :name
- ##
- # Initialize the Category
- #
- # +name+ is the name of the current Category
- # +context+ is the Liquid:Tag context
- #
- def initialize(name, context)
- @name = name
- @context = context
- end
- ##
- # Compare this Category against another Category.
- # Comparison is a comparison between the 2 names.
- #
- def <=>(other)
- return nil unless name.is_a? String
- name <=> other.name
- end
- end
- class Categories
- ##
- # Initialize the list of categories by passing a list of Jekyll::Documents.
- #
- # +category_names+ A list of strings representing a list of categories.
- # +context+ is the Liquid:Tag context
- #
- def initialize(category_names, context)
- category_names = [category_names] unless category_names.is_a? Array
- byebug
- @category_list = category_names.map{|string| Category.new(string, context)}
- end
- end
- (byebug) category_names.map
- #<Enumerator: ["Heroku"]:map>
- (byebug) Category.new("Heroku", context)
- #<Jekyll::Category:0x00000002ee6b80>
- (byebug) cat = Category.new("Heroku", context)
- #<Jekyll::Category:0x00000002a85000>
- (byebug) @category_list = [cat]
- *Error in evaluation*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement