Class: Osu::Beatmap

Inherits:
Object
  • Object
show all
Defined in:
lib/osu/data.rb

Overview

An Osu! beatmap

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Beatmap


199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/osu/data.rb', line 199

def initialize(data)
  @set_id = data['beatmapset_id'].to_i
  @id = data['beatmap_id'].to_i

  @approval = API::APPROVAL.fetch data['approved'].to_i

  @total_length = data['total_length'].to_i
  @hit_length = data['hit_length'].to_i

  @version = data['version']

  @md5 = data['file_md5']

  @difficulty = {
    size: data['diff_size'].to_i,
    overall: data['diff_overall'].to_i,
    approach: data['diff_approach'].to_i,
    drain: data['diff_drain'].to_i,
    rating: data['difficultyrating'].to_f
  }

  @mode = API::MODE.at data['mode'].to_i

  @approved_date = Time.parse data['approved_date'] unless data['approved_date'].nil?
  @last_update = Time.parse data['last_update']

  @artist = data['artist']
  @title = data['title']
  @creator = data['creator']

  @bpm = data['bpm'].to_i

  @source = data['source']
  @tags = data['tags'].split(' ')

  @genre_id = data['genre_id'].to_i
  @language_id = data['language_id'].to_i

  @favourite_count = data['favourite_count'].to_i
  @play_count = data['playcount'].to_i
  @pass_count = data['passcount'].to_i

  @max_combo = data['max_combo'].to_i
end

Instance Attribute Details

#approvalSymbol (readonly)


137
138
139
# File 'lib/osu/data.rb', line 137

def approval
  @approval
end

#approved_dateTime (readonly)


158
159
160
# File 'lib/osu/data.rb', line 158

def approved_date
  @approved_date
end

#artistString (readonly)


164
165
166
# File 'lib/osu/data.rb', line 164

def artist
  @artist
end

#bpmInteger (readonly)


173
174
175
# File 'lib/osu/data.rb', line 173

def bpm
  @bpm
end

#creatorString (readonly)


170
171
172
# File 'lib/osu/data.rb', line 170

def creator
  @creator
end

#difficultyHash<Symbol, Integer> (readonly)


152
153
154
# File 'lib/osu/data.rb', line 152

def difficulty
  @difficulty
end

#favourite_countInteger (readonly)


188
189
190
# File 'lib/osu/data.rb', line 188

def favourite_count
  @favourite_count
end

#genre_idInteger (readonly)


182
183
184
# File 'lib/osu/data.rb', line 182

def genre_id
  @genre_id
end

#hit_lengthInteger (readonly)


143
144
145
# File 'lib/osu/data.rb', line 143

def hit_length
  @hit_length
end

#idInteger (readonly)


134
135
136
# File 'lib/osu/data.rb', line 134

def id
  @id
end

#language_idInteger (readonly)


185
186
187
# File 'lib/osu/data.rb', line 185

def language_id
  @language_id
end

#last_updateTime (readonly)


161
162
163
# File 'lib/osu/data.rb', line 161

def last_update
  @last_update
end

#max_comboInteger (readonly)


197
198
199
# File 'lib/osu/data.rb', line 197

def max_combo
  @max_combo
end

#md5String (readonly)


149
150
151
# File 'lib/osu/data.rb', line 149

def md5
  @md5
end

#modeSymbol (readonly)


155
156
157
# File 'lib/osu/data.rb', line 155

def mode
  @mode
end

#pass_countInteger (readonly)


194
195
196
# File 'lib/osu/data.rb', line 194

def pass_count
  @pass_count
end

#play_countInteger (readonly)


191
192
193
# File 'lib/osu/data.rb', line 191

def play_count
  @play_count
end

#set_idInteger (readonly)


131
132
133
# File 'lib/osu/data.rb', line 131

def set_id
  @set_id
end

#sourceString (readonly)


176
177
178
# File 'lib/osu/data.rb', line 176

def source
  @source
end

#tagsArray<String> (readonly)


179
180
181
# File 'lib/osu/data.rb', line 179

def tags
  @tags
end

#titleString (readonly)


167
168
169
# File 'lib/osu/data.rb', line 167

def title
  @title
end

#total_lengthInteger (readonly)


140
141
142
# File 'lib/osu/data.rb', line 140

def total_length
  @total_length
end

#versionString (readonly)


146
147
148
# File 'lib/osu/data.rb', line 146

def version
  @version
end

Instance Method Details

#approved?true, false


255
256
257
# File 'lib/osu/data.rb', line 255

def approved?
  API::APPROVAL.key(@approval) > 0
end

#urlString


245
246
247
# File 'lib/osu/data.rb', line 245

def url
  "#{API::BASE_URL}/b/#{id}"
end