Module: KodiClient::Extensions::Comparable

Included in:
KodiError, KodiResponse, Types::Addons::AddonDependency, Types::Addons::AddonDetails, Types::Addons::AddonExtraInfo, Types::Addons::GetAddonReturned, Types::Addons::GetAddonsReturned, Types::Application::PropertyValue, Types::Application::Version, Types::Audio::AudioArtistRole, Types::Audio::AudioContributor, Types::Audio::AudioDetailsAlbum, Types::Audio::AudioDetailsArtist, Types::Audio::AudioDetailsRole, Types::Audio::AudioDetailsSong, Types::Audio::AvailableArt, Types::Audio::Genre, Types::Audio::GetAlbumsReturned, Types::Audio::GetArtistsReturned, Types::Audio::GetGenresReturned, Types::Audio::GetRolesReturned, Types::Audio::GetSongsReturned, Types::Audio::GetSourcesReturned, Types::Audio::PropertyValue, Types::Favourites::DetailsFavourite, Types::Favourites::GetFavouriteReturned, Types::Files::FileLabel, Types::Files::GetDirectoryReturned, Types::Files::GetSourcesReturned, Types::Files::PrepareDownloadReturned, Types::GUI::PropertyValue, Types::GUI::StereoscopyMode, Types::Global::GlobalTime, Types::Global::IdLabel, Types::Global::IdName, Types::Library::AudioDetailsSource, Types::Library::LibraryDetailsGenre, Types::List::ListItemAll, Types::List::ListItemFile, Types::List::ListLimits, Types::List::ListLimitsReturned, Types::List::ListSort, Types::Media::MediaArtwork, Types::Player::AudioStream, Types::Player::Player, Types::Player::PlayerPositionTime, Types::Player::PlayerViewMode, Types::Player::PropertyValue, Types::Player::SeekReturned, Types::Player::Subtitle, Types::Player::VideoStream, Types::Profiles::DetailsProfile, Types::Profiles::GetProfilesReturned, Types::Profiles::ProfilePassword, Types::System::PropertyValue, Types::Video::StreamDetails, Types::Video::VideoCast, Types::Video::VideoResume
Defined in:
lib/kodi_client/extensions/comparable.rb

Overview

offers compare methods

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Boolean

compares all Comparables using the defined compare method

Parameters:

  • other (Object)

    the object to compare with

Returns:

  • (Boolean)

    true if equal, else false



24
25
26
# File 'lib/kodi_client/extensions/comparable.rb', line 24

def ==(other)
  compare(self, other)
end

#compare(obj1, obj2) ⇒ Boolean

compares the instance variables of 2 objects for equality

Parameters:

  • obj1

    object 1

  • obj2

    object 2

Returns:

  • (Boolean)

    true if both instance variables are the same, else false



12
13
14
15
16
17
18
19
# File 'lib/kodi_client/extensions/comparable.rb', line 12

def compare(obj1, obj2)
  is_same = true
  obj1.instance_variables.each do |it|
    is_same = false if obj1.instance_variable_get(it) != obj2.instance_variable_get(it)
  end

  is_same
end