Module: CultomePlayer
- Includes:
- Command, Environment, Events, Media, Objects, Player, Plugins, StateChecker, Utils
- Included in:
- DefaultPlayer
- Defined in:
- lib/cultome_player.rb,
lib/cultome_player/media.rb,
lib/cultome_player/utils.rb,
lib/cultome_player/events.rb,
lib/cultome_player/player.rb,
lib/cultome_player/command.rb,
lib/cultome_player/objects.rb,
lib/cultome_player/plugins.rb,
lib/cultome_player/version.rb,
lib/cultome_player/environment.rb,
lib/cultome_player/objects/song.rb,
lib/cultome_player/plugins/help.rb,
lib/cultome_player/objects/album.rb,
lib/cultome_player/objects/drive.rb,
lib/cultome_player/objects/genre.rb,
lib/cultome_player/state_checker.rb,
lib/cultome_player/objects/artist.rb,
lib/cultome_player/objects/command.rb,
lib/cultome_player/objects/response.rb,
lib/cultome_player/objects/parameter.rb,
lib/cultome_player/player/interface/basic.rb,
lib/cultome_player/player/interface/builtin_help.rb
Defined Under Namespace
Modules: Command, Environment, Events, Media, Objects, Player, Plugins, StateChecker, Utils Classes: DefaultPlayer
Constant Summary collapse
- VERSION =
"2.0.0"
Constants included from Player::Interactive
Constants included from Player::Interface::Helper
Player::Interface::Helper::VALID_SONG_ATTR
Class Method Summary collapse
-
.get_player(env = :user) ⇒ DefaultPlayer
Get an instance of DefaultPlayer.
Instance Method Summary collapse
-
#create_response(type, data) ⇒ Response
Creates a generic response.
-
#execute(user_input) ⇒ Response
Interpret a user input string as it would be typed in the console.
-
#failure(response) ⇒ Response
Creates a failure response.
-
#success(response) ⇒ Response
Creates a success response.
Methods included from StateChecker
#current_album, #current_artist, #current_playlist, #current_song, #paused?, #playback_length, #playback_position, #playing?, #shuffling?, #stopped?
Methods included from Plugins
#plugin_command_sintaxis, #plugins_respond_to?
Methods included from Plugins::Help
#command_help, #description_help, #sintaxis_help, #usage_help
Methods included from Events
#emit_event, #listeners, #register_listener
Methods included from Media
Methods included from Player::Adapter
Methods included from Player::Adapter::Mpg123
#fb_in_player, #ff_in_player, #pause_in_player, #play_in_player, #quit_in_player, #repeat_in_player, #resume_in_player, #stop_in_player
Methods included from Player::Playlist
Methods included from Player::Interactive
#begin_session, #in_session?, #terminate_session
Methods included from Player::BuiltinHelp
#description_connect, #description_disconnect, #description_enqueue, #description_fb, #description_ff, #description_next, #description_pause, #description_play, #description_prev, #description_quit, #description_repeat, #description_search, #description_show, #description_shuffle, #description_stop, #usage_connect, #usage_cultome_player, #usage_disconnect, #usage_enqueue, #usage_fb, #usage_ff, #usage_next, #usage_pause, #usage_play, #usage_prev, #usage_quit, #usage_repeat, #usage_search, #usage_show, #usage_shuffle, #usage_stop
Methods included from Player::Interface::Helper
#connect_response_msg, #format_secs, #get_files_in_tree, #get_from_playlists, #get_progress_bar, #get_progress_bar_with_labels, #insert_song, #play_inline?, #play_queue, #player_object, #process_for_search, #search_songs_with, #select_songs_with, #update_song, #whole_library
Methods included from Player::Interface::Extended
#connect, #disconnect, #enqueue, #fb, #ff, #repeat, #search, #show, #shuffle
Methods included from Player::Interface::Basic
#next, #pause, #play, #prev, #quit, #stop
Methods included from Command::Reader
#command_reader, #read_command
Methods included from Command::Processor
#get_command_format, #get_tokens, #identify_tokens, #parse, #validate_command
Methods included from Command::Language
#semantics, #sintaxis, #token_identities
Methods included from Utils
#arrange_in_columns, #display, #display_over, #is_true_value?, #swallow_stdout, #with_connection
Methods included from Environment
#config_file, #current_env, #db_adapter, #db_file, #db_log_file, #env_config, #file_types, #mplayer_pipe, #player_config, #prepare_environment, #stdout
Class Method Details
.get_player(env = :user) ⇒ DefaultPlayer
Get an instance of DefaultPlayer
96 97 98 |
# File 'lib/cultome_player.rb', line 96 def get_player(env=:user) DefaultPlayer.new(env) end |
Instance Method Details
#create_response(type, data) ⇒ Response
Creates a generic response
50 51 52 53 |
# File 'lib/cultome_player.rb', line 50 def create_response(type, data) data[:response_type] = data.keys.first unless data.has_key?(:response_type) return Response.new(type, data) end |
#execute(user_input) ⇒ Response
Interpret a user input string as it would be typed in the console.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cultome_player.rb', line 27 def execute(user_input) cmd = parse user_input # revisamos si es un built in command o un plugin action = cmd.action plugin_action = "command_#{cmd.action}".to_sym action = plugin_action if respond_to?(plugin_action) raise 'invalid command:action unknown' unless respond_to?(action) with_connection do begin send(action, cmd) rescue Exception => e s = e..split(":") failure(message: s[0], details: s[1]) end end end |
#failure(response) ⇒ Response
Creates a failure response. Handy method for #create_response
67 68 69 |
# File 'lib/cultome_player.rb', line 67 def failure(response) create_response(:failure, get_response_params(response)) end |
#success(response) ⇒ Response
Creates a success response. Handy method for #create_response
59 60 61 |
# File 'lib/cultome_player.rb', line 59 def success(response) create_response(:success, get_response_params(response)) end |