Sha256: b1d3417615fdd09edc71a0230e5fc6da73abd03c995c138bc5700920d82e641e
Contents?: true
Size: 936 Bytes
Versions: 1
Compression:
Stored size: 936 Bytes
Contents
# frozen_string_literal: true module Hearken module Command class Search attr_reader :help def initialize(library) @help = <<~EOF searches for tracks containing the specified words (in artist, title or album) ids are placed on the clipboard for convenient use with + EOF @library = library end def execute(text) terms = text.split(/\W/) matches = [] @library.tracks.each do |track| if terms.all? { |term| track.search_string.include? term } puts track matches << track.search_id end end if matches.size < 50 IO.popen("pbcopy", "w") { |clipboard| clipboard.print matches.join " " } puts "Found #{matches.size} matches (ids have been placed on clipboard)" else puts "Found #{matches.size} matches" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hearken-0.1.3 | lib/hearken/command/search.rb |