Class: GreenStripes::Track
- Inherits:
-
Object
- Object
- GreenStripes::Track
- Defined in:
- lib/greenstripes.rb,
ext/greenstripes/greenstripes.c
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#album ⇒ nil
Returns the track’s album.
- #artist(index) ⇒ nil
- #artists ⇒ Object
-
#disc ⇒ Fixnum?
Returns the index of the disc the track is on, counting from 1.
-
#duration ⇒ Fixnum
Returns the track’s duration in milliseconds.
-
#error ⇒ Object
Returns one of the constants defined in Error.
-
#index ⇒ Fixnum?
Returns the index of the track on its disc, counting from 1.
-
#loaded? ⇒ Boolean
Returns true if the track is loaded, false otherwise.
-
#name ⇒ String?
Returns the track’s name.
- #num_artists ⇒ Fixnum?
-
#popularity ⇒ Fixnum
Returns the track’s popularity as a number in the range [0, 100].
- #to_link ⇒ Object
Instance Method Details
#==(other) ⇒ Object
140 141 142 |
# File 'lib/greenstripes.rb', line 140 def ==(other) self.to_link == other.to_link end |
#album ⇒ nil
Returns the track’s album.
1104 1105 1106 1107 1108 1109 1110 |
# File 'ext/greenstripes/greenstripes.c', line 1104
static VALUE track_album(VALUE self)
{
sp_track *track;
Data_Get_Struct(self, sp_track, track);
sp_album *album = sp_track_album(track);
return album ? Data_Wrap_Struct(class_album, NULL, NULL, album) : Qnil;
}
|
#artist(index) ⇒ nil
1090 1091 1092 1093 1094 1095 1096 1097 |
# File 'ext/greenstripes/greenstripes.c', line 1090
static VALUE track_artist(VALUE self, VALUE index)
{
sp_track *track;
Data_Get_Struct(self, sp_track, track);
int i = FIX2INT(index);
sp_artist *artist = sp_track_artist(track, i);
return artist ? Data_Wrap_Struct(class_artist, NULL, NULL, artist) : Qnil;
}
|
#artists ⇒ Object
144 145 146 |
# File 'lib/greenstripes.rb', line 144 def artists FakeArray.new(self, :artists) end |
#disc ⇒ Fixnum?
Returns the index of the disc the track is on, counting from 1.
1156 1157 1158 1159 1160 1161 1162 |
# File 'ext/greenstripes/greenstripes.c', line 1156
static VALUE track_disc(VALUE self)
{
sp_track *track;
Data_Get_Struct(self, sp_track, track);
int d = sp_track_disc(track);
return d ? INT2FIX(d) : Qnil;
}
|
#duration ⇒ Fixnum
Returns the track’s duration in milliseconds.
1130 1131 1132 1133 1134 1135 1136 |
# File 'ext/greenstripes/greenstripes.c', line 1130
static VALUE track_duration(VALUE self)
{
sp_track *track;
Data_Get_Struct(self, sp_track, track);
int d = sp_track_duration(track);
return INT2FIX(d);
}
|
#error ⇒ Object
Returns one of the constants defined in Error.
1066 1067 1068 1069 1070 1071 1072 |
# File 'ext/greenstripes/greenstripes.c', line 1066
static VALUE track_error(VALUE self)
{
sp_track *track;
Data_Get_Struct(self, sp_track, track);
sp_error error = sp_track_error(track);
return INT2FIX(error);
}
|
#index ⇒ Fixnum?
Returns the index of the track on its disc, counting from 1.
1169 1170 1171 1172 1173 1174 1175 |
# File 'ext/greenstripes/greenstripes.c', line 1169
static VALUE track_index(VALUE self)
{
sp_track *track;
Data_Get_Struct(self, sp_track, track);
int i = sp_track_index(track);
return i ? INT2FIX(i) : Qnil;
}
|
#loaded? ⇒ Boolean
Returns true if the track is loaded, false otherwise.
1054 1055 1056 1057 1058 1059 |
# File 'ext/greenstripes/greenstripes.c', line 1054
static VALUE track_loaded(VALUE self)
{
sp_track *track;
Data_Get_Struct(self, sp_track, track);
return sp_track_is_loaded(track) ? Qtrue : Qfalse;
}
|
#name ⇒ String?
Returns the track’s name.
1117 1118 1119 1120 1121 1122 1123 |
# File 'ext/greenstripes/greenstripes.c', line 1117
static VALUE track_name(VALUE self)
{
sp_track *track;
Data_Get_Struct(self, sp_track, track);
const char *name = sp_track_name(track);
return name ? rb_str_new2(name) : Qnil;
}
|
#num_artists ⇒ Fixnum?
1078 1079 1080 1081 1082 1083 1084 |
# File 'ext/greenstripes/greenstripes.c', line 1078
static VALUE track_num_artists(VALUE self)
{
sp_track *track;
Data_Get_Struct(self, sp_track, track);
int n = sp_track_num_artists(track);
return n ? INT2FIX(n) : Qnil;
}
|
#popularity ⇒ Fixnum
Returns the track’s popularity as a number in the range [0, 100].
1143 1144 1145 1146 1147 1148 1149 |
# File 'ext/greenstripes/greenstripes.c', line 1143
static VALUE track_popularity(VALUE self)
{
sp_track *track;
Data_Get_Struct(self, sp_track, track);
int p = sp_track_popularity(track);
return INT2FIX(p);
}
|