class Send2MacClient::Runner

Attributes

client[RW]

Public Class Methods

new() click to toggle source
# File lib/send2mac/runner.rb, line 10
def initialize
  File.file?(config_path) ? @config = YAML.load_file(config_path) : setup_api_key
  $api_key = @config[:api_key]
  @client = Listener.new
end

Public Instance Methods

config_path() click to toggle source
# File lib/send2mac/runner.rb, line 16
def config_path
  File.expand_path("#{ENV['HOME']}/.send2mac", __FILE__)
end
run() click to toggle source
# File lib/send2mac/runner.rb, line 31
def run
  client.listen
end
setup_api_key() click to toggle source
# File lib/send2mac/runner.rb, line 20
def setup_api_key
  say("\nPlease enter your Send2Mac API Key")
  puts ""
  key    = ask("API Key:   ")
  this = {api_key: key.to_s}
  File.open(config_path, "w") do |f|
    f.write(this.to_yaml)
  end
  @config = YAML.load_file(config_path)
end