Class: Sendly::ShortLinkList

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

Overview

A page of short links with their click analytics.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ShortLinkList

Returns a new instance of ShortLinkList.



85
86
87
88
# File 'lib/sendly/links_resource.rb', line 85

def initialize(response)
  @links = (response["links"] || []).map { |l| ShortLinkListItem.new(l) }
  @total = response["total"] || @links.length
end

Instance Attribute Details

Returns The workspace's short links, newest first.

Returns:



80
81
82
# File 'lib/sendly/links_resource.rb', line 80

def links
  @links
end

#totalInteger (readonly)

Returns Total number of short links in the workspace.

Returns:

  • (Integer)

    Total number of short links in the workspace



83
84
85
# File 'lib/sendly/links_resource.rb', line 83

def total
  @total
end

Instance Method Details

#countObject Also known as: size, length



94
95
96
# File 'lib/sendly/links_resource.rb', line 94

def count
  links.length
end

#each(&block) ⇒ Object



90
91
92
# File 'lib/sendly/links_resource.rb', line 90

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

#empty?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/sendly/links_resource.rb', line 101

def empty?
  links.empty?
end

#firstObject



105
106
107
# File 'lib/sendly/links_resource.rb', line 105

def first
  links.first
end

#lastObject



109
110
111
# File 'lib/sendly/links_resource.rb', line 109

def last
  links.last
end