X-Git-Url: https://git.r.bdr.sh/rbdr/lyricli.rb/blobdiff_plain/34d0bf15a6f4009de376ceed1d7d5cca24a8dfe7..2677b890a58ffaccf47f54615cd3ae6715586ab8:/doc/Lyricli/SourceManager.html?ds=sidebyside diff --git a/doc/Lyricli/SourceManager.html b/doc/Lyricli/SourceManager.html index 2f48f97..3a37bc4 100644 --- a/doc/Lyricli/SourceManager.html +++ b/doc/Lyricli/SourceManager.html @@ -103,7 +103,20 @@
+

Overview

+
+

+Manages the different sources. SourceManager is in charge of enabling and +disabling them, as well as getting the current track. +

+ + +
+
+
+ +
@@ -121,7 +134,7 @@
  • - - (Object) available_sources(format = false) + - (Array) available_sources(format = false) @@ -135,7 +148,10 @@ -
    +

    +Returns an array with the available sources. +

    +
  • @@ -143,7 +159,7 @@
  • - - (Object) current_track + - (Hash) current_track @@ -157,7 +173,10 @@ -
    +

    +Iterates over every source to attempt to retrieve the current song. +

    +
  • @@ -179,7 +198,10 @@ -
    +

    +Disables a source. +

    +
    @@ -201,7 +223,10 @@ -
    +

    +Enables a source. +

    +
    @@ -209,7 +234,7 @@
  • - - (Object) format_sources(sources) + - (Array) format_sources(sources) @@ -223,7 +248,11 @@ -
    +

    +Adds a star to all members of the array that correspond to an active +source. +

    +
  • @@ -248,7 +277,7 @@

    -A new instance of SourceManager. +Creates a new instance of SourceManager.

    @@ -272,7 +301,10 @@ A new instance of SourceManager. -
    +

    +Resets a source. +

    +
    @@ -306,7 +338,7 @@ A new instance of SourceManager.

    -A new instance of SourceManager +Creates a new instance of SourceManager

    @@ -321,10 +353,6 @@ A new instance of SourceManager
     
     
    -6
    -7
    -8
    -9
     10
     11
     12
    @@ -332,10 +360,14 @@ A new instance of SourceManager
     14
     15
     16
    -17
    +17 +18 +19 +20 +21 -
    # File 'lib/lyricli/source_manager.rb', line 6
    +      
    # File 'lib/lyricli/source_manager.rb', line 10
     
     def initialize
       @enabled_sources = []
    @@ -364,52 +396,105 @@ A new instance of SourceManager
           

    - - (Object) available_sources(format = false) + - (Array) available_sources(format = false) + + +

    +
    +

    +Returns an array with the available sources. Optionally formats the result +so active sources are identified by an appended * +

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + format + + + (Boolean) + + + (defaults to: false) + + + — +

      +whether or not to render the stars for active sources. +

      +
      + +
    • + +
    +

    Returns:

    +
      + +
    • + + + (Array) + + + + — +

      +the names of the currently available sources. +

      +
      + +
    • - + + +
       
       
      -81
      -82
      -83
      -84
      -85
      -86
      -87
      -88
      -89
      -90
      -91
      -92
      -93
      -94
      -95
      -96
      -97
      +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122
      -
      # File 'lib/lyricli/source_manager.rb', line 81
      +      
      # File 'lib/lyricli/source_manager.rb', line 107
       
       def available_sources(format = false)
         path_root = File.expand_path(File.dirname(__FILE__))
         sources = Dir[path_root+"/sources/*.rb"].map{ |s|
           name = s.split("/").last.gsub(/\.rb/, "")
      -
      -    # Add a star to denote enabled sources
      -    name
      +    name
         }
       
         # Remove arguments (Hack?) We don't want anybody to touch tihs one.
         sources.delete("arguments")
         if format
      -    format_sources(sources)
      +    # Add a star to denote enabled sources
      +    format_sources(sources)
         else
           sources
         end
      @@ -422,41 +507,72 @@ A new instance of SourceManager
             

      - - (Object) current_track + - (Hash) current_track -

      +
      +
      +

      +Iterates over every source to attempt to retrieve the current song. +

      + + +
      +
      +
      + +

      Returns:

      +
        + +
      • + + + (Hash) + + + + — +

        +the current track, has an `:artist` and `:song` key. +

        +
        + +
      • + +
      + +
       
       
      -60
      -61
      -62
      -63
      -64
      -65
      -66
      -67
      -68
      -69
      -70
      -71
      -72
      -73
      -74
      -75
      -76
      -77
      -78
      -79
      +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99
      -
      # File 'lib/lyricli/source_manager.rb', line 60
      +      
      # File 'lib/lyricli/source_manager.rb', line 80
       
       def current_track
         track = nil
      @@ -492,27 +608,61 @@ A new instance of SourceManager
         
       
         
      -
      +
      +
      +

      +Disables a source. This only removes the source from the `enabled_sources` +configuration key. +

      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + source_name + + + (String) + + + + — +

        +the name of the source to disable +

        +
        + +
      • + +
      + + +
       
       
      -34
      -35
      -36
      -37
      -38
      -39
      -40
      -41
      -42
      -43
      -44
      -45
      +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58
      -
      # File 'lib/lyricli/source_manager.rb', line 34
      +      
      # File 'lib/lyricli/source_manager.rb', line 47
       
       def disable(source_name)
         if available_sources.include?(source_name)
      @@ -540,29 +690,64 @@ A new instance of SourceManager
         
       
         
      -
      +
      +
      +

      +Enables a source. This runs the source’s enable method and adds it to +the `enabled_sources` configuration key. It will only enable sources that +are “available” (see #available_sources) +

      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + source_name + + + (String) + + + + — +

        +the name of the source to enable +

        +
        + +
      • + +
      + + +
       
       
      -19
      -20
      -21
      -22
      -23
      -24
      -25
      -26
      -27
       28
       29
       30
       31
      -32
      +32 +33 +34 +35 +36 +37 +38 +39 +40 +41
      -
      # File 'lib/lyricli/source_manager.rb', line 19
      +      
      # File 'lib/lyricli/source_manager.rb', line 28
       
       def enable(source_name)
         if available_sources.include?(source_name)
      @@ -586,27 +771,79 @@ A new instance of SourceManager
             

      - - (Object) format_sources(sources) + - (Array) format_sources(sources) -

      +
      +
      +

      +Adds a star to all members of the array that correspond to an active source +

      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + sources + + + (Array) + + + + — +

        +the array of sources to format +

        +
        + +
      • + +
      + +

      Returns:

      +
        + +
      • + + + (Array) + + + + — +

        +the formatted array +

        +
        + +
      • + +
      + +
       
       
      -99
      -100
      -101
      -102
      -103
      -104
      +129 +130 +131 +132 +133 +134
      -
      # File 'lib/lyricli/source_manager.rb', line 99
      +      
      # File 'lib/lyricli/source_manager.rb', line 129
       
       def format_sources(sources)
         sources.map{ |s|
      @@ -628,27 +865,61 @@ A new instance of SourceManager
         
       
         
      -
      +
      +
      +

      +Resets a source. This runs the source’s reset method. It will also +disable them. +

      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + source_name + + + (String) + + + + — +

        +the name of the source to reset. +

        +
        + +
      • + +
      + + +
       
       
      -47
      -48
      -49
      -50
      -51
      -52
      -53
      -54
      -55
      -56
      -57
      -58
      +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75
      -
      # File 'lib/lyricli/source_manager.rb', line 47
      +      
      # File 'lib/lyricli/source_manager.rb', line 64
       
       def reset(source_name)
         if available_sources.include?(source_name)
      @@ -672,7 +943,7 @@ A new instance of SourceManager