Class: CanTango::Category

Inherits:
Object
  • Object
show all
Defined in:
lib/cantango/category.rb

Instance Method Summary collapse

Constructor Details

#initialize(*subjects) ⇒ Category

Returns a new instance of Category.



3
4
5
# File 'lib/cantango/category.rb', line 3

def initialize *subjects
  @subjects = subjects.flatten
end

Instance Method Details

#has_any?(subject, &block) ⇒ Boolean

test if a particular category has a certain subject

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/cantango/category.rb', line 12

def has_any? subject, &block
  found = subjects.include? subject
  yield if found && block
  found
end

#subjectsObject



7
8
9
# File 'lib/cantango/category.rb', line 7

def subjects
  @subjects ||= []
end