Class: Totsuzennoshi

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

Constant Summary collapse

HEADER_LR =
"_"
HEADER_BODY =
""
HEADER_SPACE =
" "
BODY_LEFT =
""
BODY_RIGHT =
""
""
"Y^"
"Y"

Class Method Summary collapse

Class Method Details

.header_parts(message) ⇒ Object



17
18
19
20
21
# File 'lib/totsuzennoshi.rb', line 17

def self.header_parts(message)
  length = message.size
  modarray = length.divmod(2)
  return [modarray[0] + modarray[1], modarray[0]]
end

.make_body(message) ⇒ Object



32
33
34
# File 'lib/totsuzennoshi.rb', line 32

def self.make_body(message)
  return "#{BODY_LEFT}#{message}#{BODY_RIGHT}"
end


23
24
25
# File 'lib/totsuzennoshi.rb', line 23

def self.make_footer(message)
  return "#{FOOTER_LR}#{FOOTER_BODY*message.size}#{FOOTER_BODY_FILL}#{FOOTER_LR}"
end

.make_header(message) ⇒ Object



27
28
29
30
# File 'lib/totsuzennoshi.rb', line 27

def self.make_header(message)
  parts = header_parts(message)
  return "#{HEADER_LR}#{HEADER_BODY*parts[0]}#{HEADER_SPACE}#{HEADER_BODY*parts[1]}#{HEADER_LR}"
end

.totsuzennoshi(message) ⇒ Object



13
14
15
# File 'lib/totsuzennoshi.rb', line 13

def self.totsuzennoshi(message)
  return "#{make_header(message)}\n#{make_body(message)}\n#{make_footer(message)}\n"
end