class AudioAddict::Commands::SetCmd
Public Instance Methods
run()
click to toggle source
# File lib/audio_addict/commands/set.rb, line 21 def run channel = args["CHANNEL"] network = args["NETWORK"] full_set = (channel and network) || !(channel or network) if full_set set_both channel, network else set_channel channel end end
Private Instance Methods
channel_prompt(channels)
click to toggle source
# File lib/audio_addict/commands/set.rb, line 86 def channel_prompt(channels) options = channels.map { |channel| ["#{channel.name.ljust 20} # #{channel.key}", channel.key] }.to_h options = { "Cancel" => :cancel }.merge options prompt.select "Channel :", options, symbols: { marker: ">" }, filter: true end
network_prompt(networks)
click to toggle source
# File lib/audio_addict/commands/set.rb, line 92 def network_prompt(networks) options = networks.invert options["Skip"] = :cancel prompt.select "Network :", options, symbols: { marker: ">" }, filter: true, per_page: 10 end
save_channel(channel, echo: true)
click to toggle source
# File lib/audio_addict/commands/set.rb, line 98 def save_channel(channel, echo: true) Config.channel = channel Config.save say "Channel : !txtgrn!#{radio.name} > #{current_channel.name}!txtrst! # #{channel}" if echo end
save_network(network, echo: true)
click to toggle source
# File lib/audio_addict/commands/set.rb, line 104 def save_network(network, echo: true) Config.network = network Config.save say "Network : !txtgrn!#{radio.name}!txtrst! # #{network}" if echo end
set_both(channel, network)
click to toggle source
# File lib/audio_addict/commands/set.rb, line 36 def set_both(channel, network) needs :session_key if !network or !Radio.valid_network? network network_menu network elsif Radio.valid_network? network save_network network end set_channel channel end
set_channel(channel)
click to toggle source
# File lib/audio_addict/commands/set.rb, line 48 def set_channel(channel) needs :network, :session_key if !channel channel_menu elsif channel == "-" save_channel radio.channels.keys.first elsif radio.valid_channel? channel save_channel channel elsif radio.search(channel).any? channel_menu channel else say "!txtred!Invalid channel: #{radio.name} > #{channel}" end end