Class: ShellCast::Player
- Inherits:
-
Object
- Object
- ShellCast::Player
- Defined in:
- lib/shellcast/player.rb
Constant Summary collapse
- HEADER =
<<-EOH █ ███ ███ ▓███▒ █ █ █ ░███▒ █ █▓ ░█ █ █ █ ░█▒ ░█ █ █ █▒██▒ ███ █ █ █▒ ░███░ ▒███▒ █████ █▓░ █▓ ▒█ ▓▓ ▒█ █ █ █ █▒ ▒█ █▒ ░█ █ ▓██▓ █ █ █ █ █ █ █ █ █▒░ █ ▓█ █ █ █████ █ █ █ ▒████ ░███▒ █ █ █ █ █ █ █ █▒ █▒ █ ▒█ █ █░ ▓█ █ █ ▓▓ █ █░ █░ ░█▒ ░▓ █░ ▓█ █░ ▒█ █░ ▒████░ █ █ ███▒ ▒██ ▒██ ▒███▒ ▒██▒█ ▒███▒ ▒██ .----------------. ' Playback started ' EOH
- FOOTER =
<<-EOF █ █ ███████ █ ██████ █ █ █ █ █ █ █▒██▒ ███ █ █▒██▒ ██▓█ █ █▓ ▒█ ▓▓ ▒█ █ █▓ ▒█ █▓ ▓█ █ █ █ █ █ ██████ █ █ █ █ █ █ █ █████ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ▓▓ █ █ █ █ █▓ ▓█ █ █ █ ███▒ ██████ █ █ ██▓█ EOF
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id) ⇒ Player
constructor
A new instance of Player.
- #play ⇒ Object
Constructor Details
#initialize(id) ⇒ Player
Returns a new instance of Player.
79 80 81 |
# File 'lib/shellcast/player.rb', line 79 def initialize(id) @shellcast_id = id end |
Class Method Details
.list ⇒ Object
72 73 74 75 76 77 |
# File 'lib/shellcast/player.rb', line 72 def self.list Dir[File.join(ShellCast::DATA_DIR, "**", 'meta')].each do |path| = JSON.parse(IO.read(path)) puts "#{["created_at"]}: #{["title"]}" end end |
.play(id) ⇒ Object
43 44 45 |
# File 'lib/shellcast/player.rb', line 43 def self.play(id) new(id).play end |
.play_remote(url) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/shellcast/player.rb', line 47 def self.play_remote(url) puts ".==> Fetching #{url}".white_on_black resp = Net::HTTP.get(URI.parse(url)) parts = JSON.parse(resp) print "| Title:\t".yellow puts parts['title'] print "| Description:\t".yellow puts parts['description'] Dir.mktmpdir do |dir| %w(typescript timing).each do |type| File.open(File.join(dir, type), 'w') { |f| f.puts(parts[type]) } end puts "+==> Playing... ".white_on_black system "scriptreplay #{File.join(dir, 'timing')} #{File.join(dir, 'typescript')}" puts "+\n+" print "| Title:\t".yellow puts parts['title'] print "| Description:\t".yellow puts parts['description'] puts "`==> The end... ".white_on_black end end |