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.



766
767
768
769
770
771
772
773
# File 'lib/sendly/types.rb', line 766

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.



764
765
766
# File 'lib/sendly/types.rb', line 764

def data
  @data
end

#has_moreObject (readonly)

Returns the value of attribute has_more.



764
765
766
# File 'lib/sendly/types.rb', line 764

def has_more
  @has_more
end

#limitObject (readonly)

Returns the value of attribute limit.



764
765
766
# File 'lib/sendly/types.rb', line 764

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



764
765
766
# File 'lib/sendly/types.rb', line 764

def offset
  @offset
end

#totalObject (readonly)

Returns the value of attribute total.



764
765
766
# File 'lib/sendly/types.rb', line 764

def total
  @total
end

Instance Method Details

#countObject Also known as: size, length



779
780
781
# File 'lib/sendly/types.rb', line 779

def count
  data.length
end

#each(&block) ⇒ Object



775
776
777
# File 'lib/sendly/types.rb', line 775

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

#empty?Boolean

Returns:

  • (Boolean)


786
787
788
# File 'lib/sendly/types.rb', line 786

def empty?
  data.empty?
end

#firstObject



790
791
792
# File 'lib/sendly/types.rb', line 790

def first
  data.first
end

#lastObject



794
795
796
# File 'lib/sendly/types.rb', line 794

def last
  data.last
end