lib/hook/hookapp.rb
# Output an array of hooks in the given format.
Output an array of hooks in the given format.
Output an array of hooks in the given format .
def output_array(hooks_arr, opts)
    if !hooks_arr.empty?
      hooks_arr.reject! { |h| h[:path].nil? || h[:path] == '' } if opts[:files_only]
      output = []
      case opts[:format]
      when /^m/
        hooks_arr.each do |h|
          if h[:name].empty?
            title = h[:url]
          else
            title = h[:name]
          end
          output.push("- [#{title}](#{h[:url]})")
        end
      when /^p/
        hooks_arr.each do |h|
          output.push(h[:path].nil? ? h[:url] : h[:path])
        end
      when /^h/
        hooks_arr.each do |h|
          output.push(h[:url])
        end
      else
        hooks_arr.each do |h|
          output.push("Title: #{h[:name]}\nPath: #{h[:path]}\nAddress: #{h[:url]}\n---------------------")
        end
      end
    else
      warn 'No bookmarks'
    end
    output
  end
def output_array ( hooks_arr , opts ) if ! hooks_arr . empty? hooks_arr . reject! { | h | h [ :path ] . nil? || h [ :path ] == '' } if opts [ :files_only ] output = [ ] case opts [ :format ] when / ^m / hooks_arr . each do | h | if h [ :name ] . empty? title = h [ :url ] else title = h [ :name ] end output . push ( "- [#{title}](#{h[:url]})" ) end when / ^p / hooks_arr . each do | h | output . push ( h [ :path ] . nil? ? h [ :url ] : h [ :path ] ) end when / ^h / hooks_arr . each do | h | output . push ( h [ :url ] ) end else hooks_arr . each do | h | output . push ( "Title: #{h[:name]}\nPath: #{h[:path]}\nAddress: #{h[:url]}\n---------------------" ) end end else warn 'No bookmarks' end output end
Output an array of hooks in the given format.
Output an array of hooks in the given format .
hooks_arr
<not_specific>
opts
<not_specific>