Class: Dummer::Generator::InputMode

Inherits:
AbstractMode show all
Defined in:
lib/dummer/generator/input_mode.rb

Class Method Summary collapse

Methods inherited from AbstractMode

tag_proc

Class Method Details

.message_proc(input) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dummer/generator/input_mode.rb', line 4

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



21
22
23
24
25
# File 'lib/dummer/generator/input_mode.rb', line 21

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