Class: Dummer::Generator::Input

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

Class Method Summary collapse

Class Method Details

.message_proc(input) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/dummer/generator.rb', line 52

def self.message_proc(input)
  messages = nil
  begin
    open(input) do |in_file|
      messages = in_file.readlines
    end
  rescue Errno::ENOENT
    raise ConfigError.new("Input file `#{input}` is not readable")
  end
  idx = -1
  size = messages.size
  Proc.new {
    idx = (idx + 1) % size
    messages[idx]
  }
end

.record_proc(input) ⇒ Object



69
70
71
72
73
# File 'lib/dummer/generator.rb', line 69

def self.record_proc(input)
  # ToDo: implement parser
  message_proc = message_proc(input)
  Proc.new { { "message" => message_proc.call } }
end