Sha256: 96bad7d9ec69ac45f6f402918fe92077b8b6efac3555c469ba43697658128bd0

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8
module Ayadn

	class StreamMarkerObject

		attr_reader :input, :name, :updated_at, :version, :last_read_id, :percentage, :id

		def initialize hash
			@input = hash["marker"].nil? ? {} : hash["marker"]
			@name = @input["name"]
			@updated_at = @input["updated_at"]
			@version = @input["version"]
			@last_read_id = @input["last_read_id"]
			@percentage = @input["percentage"]
			@id = @input["id"]
		end
	end

	class StreamMetaObject

		attr_reader :input, :marker, :min_id, :code, :max_id, :more

		def initialize hash
			@input = hash["meta"].nil? ? {} : hash["meta"]
			@marker = hash["meta"].nil? ? nil : StreamMarkerObject.new(@input)
			@min_id = @input["min_id"]
			@code = @input["code"]
			@max_id = @input["max_id"]
			@more = @input["more"]
		end
	end

	class StreamDataObject

		attr_reader :input, :posts

		def initialize hash
			@input = hash["data"]
      		@posts = @input.blank? ? [] : @input.map { |post| PostObject.new(post) }
		end
	end

  class StreamObject

  	attr_reader :input, :meta, :data, :posts
    attr_accessor :view

  	def initialize hash
  		@input = hash
  		@meta = StreamMetaObject.new(@input)
  		@data = StreamDataObject.new(@input)
      @posts = @data.posts
  	end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ayadn-4.0.3 lib/ayadn/stream_object.rb
ayadn-4.0.2 lib/ayadn/stream_object.rb
ayadn-4.0.1 lib/ayadn/stream_object.rb
ayadn-4.0 lib/ayadn/stream_object.rb