Class: Metaa::TagCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/metaa/tag_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(tags = []) ⇒ TagCollection

Returns a new instance of TagCollection.



3
4
5
# File 'lib/metaa/tag_collection.rb', line 3

def initialize(tags = [])
  add(tags)
end

Instance Method Details

#add(new_tags) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/metaa/tag_collection.rb', line 15

def add(new_tags)
  new_tags = [new_tags] if !new_tags.is_a? Array
  new_tags.each do |tag|
    tag = Tag.new(tag) if !tag.is_a?(Tag)
    tags << tag
  end
end

#empty?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/metaa/tag_collection.rb', line 11

def empty?
  tags.empty?
end

#tagsObject



7
8
9
# File 'lib/metaa/tag_collection.rb', line 7

def tags
  @tags ||= []
end

#to_htmlObject



23
24
25
# File 'lib/metaa/tag_collection.rb', line 23

def to_html
  tags.map(&:to_html).join.html_safe
end