Module: Gemwarrior::Hr

Extended by:
Hr
Included in:
Hr
Defined in:
lib/gemwarrior/misc/hr.rb

Instance Method Summary collapse

Instance Method Details



11
12
13
# File 'lib/gemwarrior/misc/hr.rb', line 11

def print(*patterns)
  Kernel.print string(*patterns)
end

#string(*patterns) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gemwarrior/misc/hr.rb', line 15

def string(*patterns)
  options = patterns.last.is_a?(Hash) ? patterns.pop : {}
  screen_width = GameOptions.data['wrap_width']
  output = patterns.map do |pattern|
    pattern = pattern.to_s
    times = (screen_width / pattern.length) + 1
    (pattern * times)[0..screen_width - 1]
  end.join
  output << "\n"
  options = options.inject({}){|tmp,(k,v)| tmp[k.to_sym] = v.to_sym; tmp}
  options.any? ? output.colorize(options) : output
end