Class: Mandy::ArraySerializer
- Inherits:
-
Object
- Object
- Mandy::ArraySerializer
- Defined in:
- lib/mandy/support/array_serializer.rb
Constant Summary collapse
- SEPERATOR =
'|'
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(items) ⇒ ArraySerializer
constructor
A new instance of ArraySerializer.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(items) ⇒ ArraySerializer
Returns a new instance of ArraySerializer.
8 9 10 |
# File 'lib/mandy/support/array_serializer.rb', line 8 def initialize(items) @items = items || [] end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
6 7 8 |
# File 'lib/mandy/support/array_serializer.rb', line 6 def items @items end |
Class Method Details
.from_s(str) ⇒ Object
24 25 26 |
# File 'lib/mandy/support/array_serializer.rb', line 24 def self.from_s(str) str.split(SEPERATOR) end |
Instance Method Details
#==(other) ⇒ Object
16 17 18 |
# File 'lib/mandy/support/array_serializer.rb', line 16 def ==(other) (self.class == other.class && self.items == other.items) || (other.is_a?(Array) && self.items == other) end |
#to_a ⇒ Object
20 21 22 |
# File 'lib/mandy/support/array_serializer.rb', line 20 def to_a @items end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/mandy/support/array_serializer.rb', line 12 def to_s @items.join(SEPERATOR) end |