Class: Tag
- Inherits:
-
Object
- Object
- Tag
- Defined in:
- lib/glue/taggable.rb
Overview
The default Tag implementation. A tag attaches semantics to a given object. – FIXME: use index and char() instead of String. ++
Class Method Summary collapse
-
.total_frequency(tags = Tag.all) ⇒ Object
Helper method.
Instance Method Summary collapse
-
#initialize(name = nil) ⇒ Tag
constructor
A new instance of Tag.
-
#tag(obj) ⇒ Object
– FIXME: use update_properties here! ++.
-
#tagged ⇒ Object
Return all tagged objects from all categories.
- #to_s ⇒ Object
Constructor Details
#initialize(name = nil) ⇒ Tag
Returns a new instance of Tag.
18 19 20 21 |
# File 'lib/glue/taggable.rb', line 18 def initialize(name = nil) @name = name @count = 0 end |
Class Method Details
.total_frequency(tags = Tag.all) ⇒ Object
Helper method
44 45 46 |
# File 'lib/glue/taggable.rb', line 44 def self.total_frequency( = Tag.all) .inject(1) { |total, t| total += t.count } end |
Instance Method Details
#tag(obj) ⇒ Object
– FIXME: use update_properties here! ++
27 28 29 30 31 32 33 34 |
# File 'lib/glue/taggable.rb', line 27 def tag(obj) class_name = obj.class.name method_name = class_name.index('::') ? (class_name =~ /.*?\:\:(.*)/; $1) : class_name send(method_name.pluralize.underscore.to_sym) << obj @count += 1 save! end |
#tagged ⇒ Object
Return all tagged objects from all categories.
38 39 40 |
# File 'lib/glue/taggable.rb', line 38 def tagged # TODO. end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/glue/taggable.rb', line 48 def to_s @name end |