Module: Hallon::Linkable

Included in:
Album, Artist, Image, Playlist, Search, Track, User
Defined in:
lib/hallon/linkable.rb

Overview

Note:

Linkable is part of Hallons’ private API. You probably do not not need to care about these methods.

Methods shared between objects that can be created from Spotify URIs, or can be turned into Spotify URIs.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(other) ⇒ Object

Will extend other with ClassMethods on inclusion.

Parameters:

  • other (#extend)

109
110
111
# File 'lib/hallon/linkable.rb', line 109

def self.included(other)
  other.extend ClassMethods
end

Instance Method Details

#===(other) ⇒ Boolean

Compare the Linkable to other. If other is a Linkable, also compare their to_link if necessary.

Parameters:

  • other (Object)

Returns:

  • (Boolean)

128
129
130
131
132
# File 'lib/hallon/linkable.rb', line 128

def ===(other)
  super or if other.respond_to?(:to_link)
    to_link == other.to_link
  end
end

#to_strString

Note:

Returns an empty string if the #to_link call fails.

Converts the Linkable first to a Link, and then that link to a String.

Returns:

  • (String)

117
118
119
120
121
# File 'lib/hallon/linkable.rb', line 117

def to_str
  link = to_link
  link &&= link.to_str
  link.to_s
end