Class: Tagged::TagList
- Inherits:
-
Array
- Object
- Array
- Tagged::TagList
- Defined in:
- lib/tagged/tag_list.rb
Instance Attribute Summary collapse
-
#delimiter ⇒ Object
Returns the value of attribute delimiter.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
- #+(list) ⇒ Object
-
#initialize(*list) ⇒ TagList
constructor
A new instance of TagList.
- #to_s(delimiter = nil) ⇒ Object
Constructor Details
#initialize(*list) ⇒ TagList
Returns a new instance of TagList.
4 5 6 7 8 9 10 11 12 |
# File 'lib/tagged/tag_list.rb', line 4 def initialize(*list) self.delimiter = ',' if list[0].is_a?(Array) self.delimiter = list[1] list = list[0] end list = list.is_a?(Array) ? list : list.split(self.delimiter).collect(&:strip).reject(&:blank) super(list) end |
Instance Attribute Details
#delimiter ⇒ Object
Returns the value of attribute delimiter.
3 4 5 |
# File 'lib/tagged/tag_list.rb', line 3 def delimiter @delimiter end |
#tags ⇒ Object
Returns the value of attribute tags.
3 4 5 |
# File 'lib/tagged/tag_list.rb', line 3 def @tags end |
Instance Method Details
#+(list) ⇒ Object
14 15 16 |
# File 'lib/tagged/tag_list.rb', line 14 def +(list) Tagged::TagList.new(self.to_a + list, self.delimiter) end |
#to_s(delimiter = nil) ⇒ Object
18 19 20 |
# File 'lib/tagged/tag_list.rb', line 18 def to_s(delimiter = nil) join(delimiter || self.delimiter) end |