Sha256: 21553b4935fa7545f6705ad4ce7e87e6a27d9fbd348dc63ed01663b3a63a9b9b
Contents?: true
Size: 897 Bytes
Versions: 1
Compression:
Stored size: 897 Bytes
Contents
#!/usr/bin/env ruby require 'terminfo' # Terminal sigarette class Sijka SLEEP_TIME = 0.02 def initialize(file_name = "#{File.dirname(__FILE__)}/characters/base.txt") @img = File.open(file_name) { |file| file.read.split("\n") } @movement_range = TermInfo.screen_size[1] - @img.first.length end def smoke right_move reverse_img left_move puts 'All was smoking!' sleep(1.3) system 'clear' end def right_move @movement_range.times do system 'clear' puts @img sleep(SLEEP_TIME) @img.map! { |line| line.insert(0, ' ') } end end def reverse_img @img.map! do |line| line[0..@movement_range - 1] + line[@movement_range..-1].reverse end end def left_move @movement_range.times do system 'clear' puts @img sleep(SLEEP_TIME) @img.map! { |line| line[1..-1] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sijka-0.0.0.0 | lib/sijka.rb |