Module: MultimediaParadise::Rubio::Model::RadioBrowser

Defined in:
lib/multimedia_paradise/gui/glimmer/rubio/model/radio_browser.rb

Overview

Rubio::Model::RadioBrowser

Constant Summary collapse

BASE_URL =
#

BASE_URL

#
'http://all.api.radio-browser.info/json/'

Class Method Summary collapse

Class Method Details

.base_urlObject

#

base_url

#


32
33
34
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_browser.rb', line 32

def base_url
  BASE_URL
end

.topvote(n = 100, offset: 0) ⇒ Object

#

topvote

#


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_browser.rb', line 39

def topvote(
    n = 100, offset: 0
  )
  target_URL = base_url + "stations/topvote/#{n}?offset=#{offset}"
  content = URI.parse(target_URL)
  result = [] # Append onto the result there.
  JSON[content.read].each_with_index { |s, _i|
    result << Station.new(
      s['stationuuid'],
      s['name'],
      s['language'],
      s['country'],
      s['url_resolved']
    )
  }
  result
end