Sha256: 0e650c3a2f4c8c6e531b0061276cafc4844cf606f43479f576f95370e13b14ee

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

require './lib/marver.rb'

module Marver
  class Story
    attr_reader :id, :json, :title, :type, :resource_uri, :description, :thumbnail,
                :comics, :series, :events, :characters, :creators, :original_issue,
                :credentials

    class << self
      def build(response, credentials)
        if response.kind_of?(Array)
          response.collect do |story|
            Marver::Story.new(story, credentials)
          end
        else
          new(response.results, credentials)
        end
      end
    end

    def initialize(json, credentials)
      @credentials = credentials
      @json = json

      @title = @json['title']
      @type = @json['type']
      @resource_uri = "#{@json['resourceURI']}?#{@credentials.to_s}"
      @description = @json['description']

      @original_issue = Marver::ComicSummary.new(@json['originalIssue'], @credentials)

      CoreEntitiesBuilder.build!(self)
      CommonEntitiesBuilder.build!(self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
marver-0.0.2 lib/marver/entities/core/story.rb