Class: MultimediaParadise::Rubio::Model::RadioPresenter
- Inherits:
-
Object
- Object
- MultimediaParadise::Rubio::Model::RadioPresenter
- Defined in:
- lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb
Overview
Rubio::Model::RadioPresenter
Instance Attribute Summary collapse
-
#current_station ⇒ Object
Returns the value of attribute current_station.
-
#initial_height ⇒ Object
readonly
Returns the value of attribute initial_height.
-
#initial_width ⇒ Object
readonly
Returns the value of attribute initial_width.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#player ⇒ Object
readonly
Returns the value of attribute player.
-
#stations ⇒ Object
Returns the value of attribute stations.
-
#view ⇒ Object
Returns the value of attribute view.
-
#window_height ⇒ Object
Returns the value of attribute window_height.
Instance Method Summary collapse
-
#fetch_more_stations ⇒ Object
# === fetch_more_stations ========================================================================= #.
-
#initialize(options = {}) ⇒ RadioPresenter
constructor
# === initialize.
- #play_station ⇒ Object
-
#reset ⇒ Object
# === reset ========================================================================= #.
- #select_station(station) ⇒ Object
-
#stations_incomplete? ⇒ Boolean
# === stations_incomplete? ========================================================================= #.
-
#stop_station ⇒ Object
stop_station.
- #toggle_bookmarked_station(station) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ RadioPresenter
#
initialize
Initializes with view options below:
:backend, :initial_width, :initial_height, :radio_station_count, :debug, :show_menu, :show_page_count, :show_bookmarks, :show_margins :gradually_fetch_stations, :table_per_page
#
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 39 def initialize( = {}) reset @options = @options[:radio_station_count] = 1_000_000 if [:radio_station_count] == -1 @loaded_station_count = [[:gradually_fetch_stations] ? 100 : [:radio_station_count], [:radio_station_count]].min @loaded_station_offset = 0 @stations = Model::RadioBrowser.topvote(@loaded_station_count, offset: @loaded_station_offset) @player = Model::Player.new([:backend], show_currently_playing: [:show_currently_playing]) @initial_width = ([:initial_width] || ([:show_bookmarks] ? 740 : 620)).to_i @initial_height = ([:initial_height] || calculate_initial_height).to_i @window_height = @initial_height Glimmer::DataBinding::Observer::Proc.new { self.window_height = calculate_initial_height }.observe(@player, :currently_playing) end |
Instance Attribute Details
#current_station ⇒ Object
Returns the value of attribute current_station.
26 27 28 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 26 def current_station @current_station end |
#initial_height ⇒ Object (readonly)
Returns the value of attribute initial_height.
22 23 24 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 22 def initial_height @initial_height end |
#initial_width ⇒ Object (readonly)
Returns the value of attribute initial_width.
21 22 23 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 21 def initial_width @initial_width end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 23 def @options end |
#player ⇒ Object (readonly)
Returns the value of attribute player.
20 21 22 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 20 def player @player end |
#stations ⇒ Object
Returns the value of attribute stations.
25 26 27 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 25 def stations @stations end |
#view ⇒ Object
Returns the value of attribute view.
27 28 29 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 27 def view @view end |
#window_height ⇒ Object
Returns the value of attribute window_height.
28 29 30 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 28 def window_height @window_height end |
Instance Method Details
#fetch_more_stations ⇒ Object
#
fetch_more_stations
#
104 105 106 107 108 109 110 111 112 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 104 def fetch_more_stations @loaded_station_offset += @loaded_station_count @loaded_station_count *= 2 new_station_count = [@loaded_station_count, [:radio_station_count] - @loaded_station_offset].min old_station_count = @stations.count self.stations += Model::RadioBrowser.topvote(new_station_count, offset: @loaded_station_offset) @all_stations_fetched = @stations.count == old_station_count self.stations end |
#play_station ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 78 def play_station @player.play(current_station.url, station_name: current_station.name) current_station. = true rescue => error self.current_station = nil raise error end |
#reset ⇒ Object
#
reset
#
58 59 60 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 58 def reset @view = :all end |
#select_station(station) ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 62 def select_station(station) = station. stop_station self.current_station = station if self.current_station = nil else play_station end end |
#stations_incomplete? ⇒ Boolean
#
stations_incomplete?
#
97 98 99 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 97 def stations_incomplete? !@all_stations_fetched && @stations.count < [:radio_station_count] end |
#stop_station ⇒ Object
stop_station
87 88 89 90 91 92 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 87 def stop_station return if current_station.nil? @player.stop current_station. = false self.current_station = nil end |
#toggle_bookmarked_station(station) ⇒ Object
73 74 75 76 |
# File 'lib/multimedia_paradise/gui/glimmer/rubio/model/radio_presenter.rb', line 73 def toggle_bookmarked_station(station) return unless station station.bookmarked = !station.bookmarked? end |