Sha256: dddd842b0e191ea4887c0c9b20fd41fefd7cdd7fe609056c62421fb99f7ab347

Contents?: true

Size: 582 Bytes

Versions: 91

Compression:

Stored size: 582 Bytes

Contents

module Mandy
  class ArraySerializer
    
    SEPERATOR = '|' unless defined?(SEPERATOR)
    
    attr_reader :items
    
    def initialize(items)
      @items = items || []
    end
    
    def to_s
      @items.join(SEPERATOR)
    end
    
    def ==(other)
      (self.class == other.class && self.items == other.items) || (other.is_a?(Array) && self.items == other)
    end
    
    def to_a
      @items
    end
    
    def self.from_s(str)
      str.split(SEPERATOR)
    end
    
    def self.tuples_from_s(str)
      from_s(str).map {|s| Tuple.from_s(s) }
    end
  end
end

Version data entries

91 entries across 91 versions & 2 rubygems

Version Path
trafficbroker-mandy-0.1.7 lib/support/array_serializer.rb
trafficbroker-mandy-0.1.8 lib/support/array_serializer.rb
trafficbroker-mandy-0.1.9 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.10 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.11 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.12 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.13 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.2 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.3 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.4.2 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.4.3 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.4.4 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.4.5 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.4.6 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.4 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.5.1 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.5 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.6 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.7 lib/support/array_serializer.rb
trafficbroker-mandy-0.2.8 lib/support/array_serializer.rb