module Tunees::Application

Public Class Methods

_execute(script) click to toggle source
# File lib/tunees/application.rb, line 8
    def self._execute(script)
      Commander.run <<-JXA.strip_heredoc
        var app = Application("iTunes")
        #{script}

        // TODO: make this recursively
        if (Array.isArray(ret)) {
          return ret.map(function(x) { return x.properties() })
        } else if (typeof ret == 'object') {
          return ret.properties()
        } else if (typeof ret == 'function') {
          return ret.properties()
        } else {
          return ret
        }
      JXA
    end
execute(method, *args) click to toggle source
# File lib/tunees/application.rb, line 26
    def self.execute(method, *args)
      _execute(<<-JXA.strip_heredoc)
        var ret = app.#{method}(#{args.join(",")})
      JXA
    end
play(track) click to toggle source
# File lib/tunees/application.rb, line 67
    def self.play(track)
      case track
      when Integer
        id = track
        _execute(<<-JXA.strip_heredoc)
          var track = app.tracks.byId(#{id});
          var ret = app.play(track);
          return
        JXA
      end
    end
set_property(property, value) click to toggle source
# File lib/tunees/application.rb, line 32
    def self.set_property(property, value)
      Commander.run <<-JXA.strip_heredoc
        var app = Application("iTunes")
        app.#{property} = #{value}
      JXA
    end