Class: Sijka::Smoke

Inherits:
Object
  • Object
show all
Defined in:
lib/sijka/smoke.rb

Constant Summary collapse

SLEEP_TIME =
0.02
FILE_LIST =

TODO added method when add other screens

[ 'base' ]

Instance Method Summary collapse

Constructor Details

#initialize(name, file_name) ⇒ Smoke

Returns a new instance of Smoke.



8
9
10
11
12
13
14
15
16
# File 'lib/sijka/smoke.rb', line 8

def initialize(name, file_name)
  file_name =  !file_name.to_s.empty? && FILE_LIST.include?(file_name) ? file_name : 'base'
  file_path = "#{File.dirname(__FILE__)}/../characters/#{file_name.downcase}.txt"
  @img = File.open(file_path) { |file| file.read.split("\n") }
  @movement_range = TermInfo.screen_size[1] - @img.first.length

  message = Translator.new.smoken_with_locale
  @message_with_name = name.to_s.empty? ? "#{message}!" : "#{message}, #{name}!"
end

Instance Method Details

#smokeObject



18
19
20
21
22
23
24
25
# File 'lib/sijka/smoke.rb', line 18

def smoke
  right_move
  reverse_img
  left_move
  puts @message_with_name
  sleep(1.3)
  system 'clear'
end