Class: ShellCast::Player
- Inherits:
-
Object
- Object
- ShellCast::Player
- Defined in:
- lib/shellcast/player.rb
Constant Summary collapse
- HEADER =
" \n \u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \n \u2593\u2588\u2588\u2588\u2592 \u2588 \u2588 \u2588 \u2591\u2588\u2588\u2588\u2592 \u2588 \n \u2588\u2593 \u2591\u2588 \u2588 \u2588 \u2588 \u2591\u2588\u2592 \u2591\u2588 \u2588 \n \u2588 \u2588\u2592\u2588\u2588\u2592 \u2588\u2588\u2588 \u2588 \u2588 \u2588\u2592 \u2591\u2588\u2588\u2588\u2591 \u2592\u2588\u2588\u2588\u2592 \u2588\u2588\u2588\u2588\u2588 \n \u2588\u2593\u2591 \u2588\u2593 \u2592\u2588 \u2593\u2593 \u2592\u2588 \u2588 \u2588 \u2588 \u2588\u2592 \u2592\u2588 \u2588\u2592 \u2591\u2588 \u2588 \n \u2593\u2588\u2588\u2593 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2592\u2591 \u2588 \n \u2593\u2588 \u2588 \u2588 \u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2592\u2588\u2588\u2588\u2588 \u2591\u2588\u2588\u2588\u2592 \u2588 \n \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2592 \u2588\u2592 \u2588 \u2592\u2588 \u2588 \n \u2588\u2591 \u2593\u2588 \u2588 \u2588 \u2593\u2593 \u2588 \u2588\u2591 \u2588\u2591 \u2591\u2588\u2592 \u2591\u2593 \u2588\u2591 \u2593\u2588 \u2588\u2591 \u2592\u2588 \u2588\u2591 \n \u2592\u2588\u2588\u2588\u2588\u2591 \u2588 \u2588 \u2588\u2588\u2588\u2592 \u2592\u2588\u2588 \u2592\u2588\u2588 \u2592\u2588\u2588\u2588\u2592 \u2592\u2588\u2588\u2592\u2588 \u2592\u2588\u2588\u2588\u2592 \u2592\u2588\u2588 \n\n\n .----------------.\n ' Playback started '\n"- FOOTER =
" \u2588 \u2588 \n\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \n \u2588 \u2588 \u2588 \u2588 \n \u2588 \u2588\u2592\u2588\u2588\u2592 \u2588\u2588\u2588 \u2588 \u2588\u2592\u2588\u2588\u2592 \u2588\u2588\u2593\u2588 \n \u2588 \u2588\u2593 \u2592\u2588 \u2593\u2593 \u2592\u2588 \u2588 \u2588\u2593 \u2592\u2588 \u2588\u2593 \u2593\u2588 \n \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \n \u2588 \u2588 \u2588 \u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \n \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \n \u2588 \u2588 \u2588 \u2593\u2593 \u2588 \u2588 \u2588 \u2588 \u2588\u2593 \u2593\u2588 \n \u2588 \u2588 \u2588 \u2588\u2588\u2588\u2592 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588\u2588\u2593\u2588 \n\n"
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 "#{metadata["created_at"]}: #{metadata["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 |
Instance Method Details
#play ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/shellcast/player.rb', line 83 def play puts HEADER.black_on_white puts system(scriptreplay_cmd) puts puts FOOTER.black_on_white end |