class Lpgrid::InputReader

Constants

IncorectInputFormat

Attributes

string[R]

Public Class Methods

new(string) click to toggle source
# File lib/lpgrid/input_reader.rb, line 13
def initialize(string)
  @string = string
end
translate(string) click to toggle source
# File lib/lpgrid/input_reader.rb, line 7
def self.translate(string)
  instance = new(string)
  instance.check_format
  instance.translate
end

Public Instance Methods

check_format() click to toggle source
# File lib/lpgrid/input_reader.rb, line 17
def check_format
  if splitter.collect(&:length).select { |leng| leng !=2 } .any?
    raise IncorectInputFormat
  end
end
splitter() click to toggle source
# File lib/lpgrid/input_reader.rb, line 29
def splitter
  string.split(' ')
end
translate() click to toggle source
# File lib/lpgrid/input_reader.rb, line 23
def translate
  splitter.collect do |element|
    Grid.new(element).fetch
  end.join(' ')
end