Class: Sendly::DraftList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/sendly/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ DraftList

Returns a new instance of DraftList.



845
846
847
848
849
850
851
852
# File 'lib/sendly/types.rb', line 845

def initialize(response)
  @data = (response["data"] || []).map { |d| Draft.new(d) }
  pagination = response["pagination"] || {}
  @total = pagination["total"] || @data.length
  @limit = pagination["limit"] || 20
  @offset = pagination["offset"] || 0
  @has_more = pagination["hasMore"] || pagination["has_more"] || false
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



843
844
845
# File 'lib/sendly/types.rb', line 843

def data
  @data
end

#has_moreObject (readonly)

Returns the value of attribute has_more.



843
844
845
# File 'lib/sendly/types.rb', line 843

def has_more
  @has_more
end

#limitObject (readonly)

Returns the value of attribute limit.



843
844
845
# File 'lib/sendly/types.rb', line 843

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



843
844
845
# File 'lib/sendly/types.rb', line 843

def offset
  @offset
end

#totalObject (readonly)

Returns the value of attribute total.



843
844
845
# File 'lib/sendly/types.rb', line 843

def total
  @total
end

Instance Method Details

#countObject Also known as: size, length



858
859
860
# File 'lib/sendly/types.rb', line 858

def count
  data.length
end

#each(&block) ⇒ Object



854
855
856
# File 'lib/sendly/types.rb', line 854

def each(&block)
  data.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


865
866
867
# File 'lib/sendly/types.rb', line 865

def empty?
  data.empty?
end

#firstObject



869
870
871
# File 'lib/sendly/types.rb', line 869

def first
  data.first
end

#lastObject



873
874
875
# File 'lib/sendly/types.rb', line 873

def last
  data.last
end