class GetHappy::CLI

Constants

CAPTURE_COMMANDS_OUTPUT

Public Instance Methods

add(*links) click to toggle source
# File lib/get_happy/cli.rb, line 16
def add(*links)
  @collection ||= GetHappy.get_collection
  links.each {|link| @collection << link.to_s}
  GetHappy.write_collection(@collection)
  list
end
clean() click to toggle source
# File lib/get_happy/cli.rb, line 37
def clean
  @collection = []
  GetHappy.write_collection([])
  say "Collection is empty", :green
end
delete(url) click to toggle source
# File lib/get_happy/cli.rb, line 50
def delete(url)
  @collection = GetHappy.get_collection
  deleted = !!@collection.delete(url.to_s)
  GetHappy.write_collection(@collection)
  say deleted,  deleted ? :green : :red
end
import_playlist(id) click to toggle source
# File lib/get_happy/cli.rb, line 59
def import_playlist(id)
  GetHappy.ensure_user_data!
  
  playlist = GetHappy.get_playlist(id)
  say "Found #{playlist.size} items"
  
  unless playlist.empty?        
    if yes?("Import playlist?", :green)
      GetHappy.write_collection(playlist)
      list
    end
  end

end
list() click to toggle source
# File lib/get_happy/cli.rb, line 24
def list  
  @collection = GetHappy.get_collection
  user =  `echo $USER`.gsub("\n", "")

  say " \n"
  say "\e[1m\e[4m#{user} Total #{@collection.size}\e[0m \n\n"
  @collection.each do |item|
    say "🚀  #{item}" , :green
  end
  say "\n"
end
play() click to toggle source
# File lib/get_happy/cli.rb, line 8
def play
  @collection ||= GetHappy.get_collection
  run("open #{@collection.sample}", :capture => CAPTURE_COMMANDS_OUTPUT) unless @collection.empty?
  say "Collection is empty! get_happy seed to seed" if @collection.empty?
end
seed() click to toggle source
# File lib/get_happy/cli.rb, line 44
def seed
  GetHappy.seed
  list
end