Module: Atom::HasCategories
Class Method Summary collapse
Instance Method Summary collapse
-
#tag_with(tags, delimiter = ' ') ⇒ Object
categorize the entry with each of an array or a space-separated string.
Class Method Details
.included(klass) ⇒ Object
660 661 662 |
# File 'lib/atom/element.rb', line 660 def HasCategories.included(klass) klass.atom_elements :category, :categories, Atom::Category end |
Instance Method Details
#tag_with(tags, delimiter = ' ') ⇒ Object
categorize the entry with each of an array or a space-separated
string
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
# File 'lib/atom/element.rb', line 666 def tag_with(, delimiter = ' ') return if not or .empty? tag_list = unless .is_a?(String) else = .split(delimiter) .map! { |t| t.strip } .reject! { |t| t.empty? } .uniq end tag_list.each do |tag| unless categories.any? { |c| c.term == tag } categories.new :term => tag end end end |