Sha256: e321b9fa61936856268a20308a3ed74dfd92484f5574eafb5fdfef5a2edbe856

Contents?: true

Size: 467 Bytes

Versions: 2

Compression:

Stored size: 467 Bytes

Contents

module MyAnimeList
  class Serializer
    def initialize(data, type)
      @type = type
      @animes = data || []
    end

    def fetch
      serialize_data
    end

    def serialize_data
      return @animes if is_array? @animes

      collection = []
      data = @animes[@type]['entry']
      if is_array? data
        collection += data
      else
        collection << data
      end
    end

    def is_array?(data)
      data.is_a? Array
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
myanimelist-0.0.6 lib/myanimelist/serializer.rb
myanimelist-0.0.5 lib/myanimelist/serializer.rb