Class: Sendly::DraftList
- Inherits:
-
Object
- Object
- Sendly::DraftList
- Includes:
- Enumerable
- Defined in:
- lib/sendly/types.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#has_more ⇒ Object
readonly
Returns the value of attribute has_more.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #count ⇒ Object (also: #size, #length)
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #first ⇒ Object
-
#initialize(response) ⇒ DraftList
constructor
A new instance of DraftList.
- #last ⇒ Object
Constructor Details
#initialize(response) ⇒ DraftList
Returns a new instance of DraftList.
697 698 699 700 701 702 703 704 |
# File 'lib/sendly/types.rb', line 697 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
#data ⇒ Object (readonly)
Returns the value of attribute data.
695 696 697 |
# File 'lib/sendly/types.rb', line 695 def data @data end |
#has_more ⇒ Object (readonly)
Returns the value of attribute has_more.
695 696 697 |
# File 'lib/sendly/types.rb', line 695 def has_more @has_more end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
695 696 697 |
# File 'lib/sendly/types.rb', line 695 def limit @limit end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
695 696 697 |
# File 'lib/sendly/types.rb', line 695 def offset @offset end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
695 696 697 |
# File 'lib/sendly/types.rb', line 695 def total @total end |
Instance Method Details
#count ⇒ Object Also known as: size, length
710 711 712 |
# File 'lib/sendly/types.rb', line 710 def count data.length end |
#each(&block) ⇒ Object
706 707 708 |
# File 'lib/sendly/types.rb', line 706 def each(&block) data.each(&block) end |
#empty? ⇒ Boolean
717 718 719 |
# File 'lib/sendly/types.rb', line 717 def empty? data.empty? end |
#first ⇒ Object
721 722 723 |
# File 'lib/sendly/types.rb', line 721 def first data.first end |
#last ⇒ Object
725 726 727 |
# File 'lib/sendly/types.rb', line 725 def last data.last end |