Class: GreenStripes::ArtistBrowse
- Inherits:
-
Object
- Object
- GreenStripes::ArtistBrowse
- Defined in:
- lib/greenstripes.rb,
ext/greenstripes/greenstripes.c
Class Method Summary collapse
-
.new(session, artist) ⇒ nil
Returns a new artist browse object.
Instance Method Summary collapse
-
#artist ⇒ nil
Returns the artist for the artist browse object.
-
#biography ⇒ String?
Returns the biography for the artist browse object, or nil if no biography is available.
-
#error ⇒ Object
Returns one of the constants defined in Error.
-
#initialize(*args) ⇒ ArtistBrowse
constructor
:nodoc:.
-
#loaded? ⇒ Boolean
Returns true if the artist browse object is loaded, false otherwise.
- #num_similar_artists ⇒ Fixnum?
- #num_tracks ⇒ Fixnum?
- #similar_artist(index) ⇒ nil
- #similar_artists ⇒ Object
- #track(index) ⇒ nil
- #tracks ⇒ Object
Constructor Details
#initialize(*args) ⇒ ArtistBrowse
:nodoc:
90 91 |
# File 'lib/greenstripes.rb', line 90 def initialize(*args) # :nodoc: end |
Class Method Details
.new(session, artist) ⇒ nil
Returns a new artist browse object.
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 |
# File 'ext/greenstripes/greenstripes.c', line 699
static VALUE artist_browse_new(VALUE klass, VALUE session, VALUE artist)
{
// TODO: artist browse callback should not be hardcoded
sp_session *s;
Data_Get_Struct(session, sp_session, s);
sp_artist *a;
Data_Get_Struct(artist, sp_artist, a);
sp_artistbrowse *artistbrowse = NULL;
artistbrowse = sp_artistbrowse_create(s, a, artist_browse_complete_callback, NULL);
if(!artistbrowse)
return Qnil;
VALUE ab_value = Data_Wrap_Struct(class_artist_browse, NULL, artist_browse_free, artistbrowse);
VALUE argv[2] = {session, artist};
rb_obj_call_init(ab_value, 2, argv);
return ab_value;
}
|
Instance Method Details
#artist ⇒ nil
Returns the artist for the artist browse object.
751 752 753 754 755 756 757 |
# File 'ext/greenstripes/greenstripes.c', line 751
static VALUE artist_browse_artist(VALUE self)
{
sp_artistbrowse *artistbrowse;
Data_Get_Struct(self, sp_artistbrowse, artistbrowse);
sp_artist *artist = sp_artistbrowse_artist(artistbrowse);
return artist ? Data_Wrap_Struct(class_artist, NULL, NULL, artist) : Qnil;
}
|
#biography ⇒ String?
Returns the biography for the artist browse object, or nil if no biography is available.
817 818 819 820 821 822 823 |
# File 'ext/greenstripes/greenstripes.c', line 817
static VALUE artist_browse_biography(VALUE self)
{
sp_artistbrowse *artistbrowse;
Data_Get_Struct(self, sp_artistbrowse, artistbrowse);
const char *bio = sp_artistbrowse_biography(artistbrowse);
return bio ? rb_str_new2(bio) : Qnil;
}
|
#error ⇒ Object
Returns one of the constants defined in Error.
738 739 740 741 742 743 744 |
# File 'ext/greenstripes/greenstripes.c', line 738
static VALUE artist_browse_error(VALUE self)
{
sp_artistbrowse *artistbrowse;
Data_Get_Struct(self, sp_artistbrowse, artistbrowse);
sp_error error = sp_artistbrowse_error(artistbrowse);
return INT2FIX(error);
}
|
#loaded? ⇒ Boolean
Returns true if the artist browse object is loaded, false otherwise.
726 727 728 729 730 731 |
# File 'ext/greenstripes/greenstripes.c', line 726
static VALUE artist_browse_loaded(VALUE self)
{
sp_artistbrowse *artistbrowse;
Data_Get_Struct(self, sp_artistbrowse, artistbrowse);
return sp_artistbrowse_is_loaded(artistbrowse) ? Qtrue : Qfalse;
}
|
#num_similar_artists ⇒ Fixnum?
789 790 791 792 793 794 795 |
# File 'ext/greenstripes/greenstripes.c', line 789
static VALUE artist_browse_num_similar_artists(VALUE self)
{
sp_artistbrowse *artistbrowse;
Data_Get_Struct(self, sp_artistbrowse, artistbrowse);
int n = sp_artistbrowse_num_similar_artists(artistbrowse);
return (n >= 0) ? INT2FIX(n) : Qnil;
}
|
#num_tracks ⇒ Fixnum?
763 764 765 766 767 768 769 |
# File 'ext/greenstripes/greenstripes.c', line 763
static VALUE artist_browse_num_tracks(VALUE self)
{
sp_artistbrowse *artistbrowse;
Data_Get_Struct(self, sp_artistbrowse, artistbrowse);
int n = sp_artistbrowse_num_tracks(artistbrowse);
return (n >= 0) ? INT2FIX(n) : Qnil;
}
|
#similar_artist(index) ⇒ nil
801 802 803 804 805 806 807 808 809 |
# File 'ext/greenstripes/greenstripes.c', line 801
static VALUE artist_browse_similar_artist(VALUE self, VALUE index)
{
sp_artistbrowse *artistbrowse;
Data_Get_Struct(self, sp_artistbrowse, artistbrowse);
int i = FIX2INT(index);
sp_artist *artist = NULL;
artist = sp_artistbrowse_similar_artist(artistbrowse, i);
return artist ? Data_Wrap_Struct(class_artist, NULL, NULL, artist) : Qnil;
}
|
#similar_artists ⇒ Object
97 98 99 |
# File 'lib/greenstripes.rb', line 97 def similar_artists FakeArray.new(self, :similar_artists) end |
#track(index) ⇒ nil
775 776 777 778 779 780 781 782 783 |
# File 'ext/greenstripes/greenstripes.c', line 775
static VALUE artist_browse_track(VALUE self, VALUE index)
{
sp_artistbrowse *artistbrowse;
Data_Get_Struct(self, sp_artistbrowse, artistbrowse);
int i = FIX2INT(index);
sp_track *track = NULL;
track = sp_artistbrowse_track(artistbrowse, i);
return track ? Data_Wrap_Struct(class_track, NULL, NULL, track) : Qnil;
}
|