Class: Tags
- Inherits:
-
Object
- Object
- Tags
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/tags.rb,
lib/tags/version.rb
Constant Summary collapse
- VERSION =
"1.1.0"
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(tags) ⇒ Tags
constructor
A new instance of Tags.
- #to_s ⇒ Object
Constructor Details
#initialize(tags) ⇒ Tags
Returns a new instance of Tags.
9 10 11 12 13 |
# File 'lib/tags.rb', line 9 def initialize() @tags = .is_a?(Array) ? : .to_s.split(/\W+/) @tags.each &:downcase! @tags.uniq! end |
Instance Method Details
#+(other) ⇒ Object
19 20 21 |
# File 'lib/tags.rb', line 19 def +(other) self.class.new(to_a + other.to_a) end |
#-(other) ⇒ Object
23 24 25 |
# File 'lib/tags.rb', line 23 def -(other) self.class.new(to_a - other.to_a) end |
#==(other) ⇒ Object
27 28 29 |
# File 'lib/tags.rb', line 27 def ==(other) to_a == Array(other) end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/tags.rb', line 15 def to_s .join ', ' end |