Class: L43Rmap::Runtime

Inherits:
Object
  • Object
show all
Defined in:
lib/l43_rmap/runtime.rb,
lib/l43_rmap/runtime/line_time.rb

Defined Under Namespace

Classes: LineTime

Constant Summary collapse

DefaultDecRandomMax =
10_000

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#chunksObject (readonly)

Returns the value of attribute chunks.



8
9
10
# File 'lib/l43_rmap/runtime.rb', line 8

def chunks
  @chunks
end

#currentObject (readonly)

Returns the value of attribute current.



8
9
10
# File 'lib/l43_rmap/runtime.rb', line 8

def current
  @current
end

#input_streamObject (readonly)

Returns the value of attribute input_stream.



8
9
10
# File 'lib/l43_rmap/runtime.rb', line 8

def input_stream
  @input_stream
end

#output_streamObject (readonly)

Returns the value of attribute output_stream.



8
9
10
# File 'lib/l43_rmap/runtime.rb', line 8

def output_stream
  @output_stream
end

#randObject (readonly)

Returns the value of attribute rand.



8
9
10
# File 'lib/l43_rmap/runtime.rb', line 8

def rand
  @rand
end

#terminatedObject (readonly)

Returns the value of attribute terminated.



8
9
10
# File 'lib/l43_rmap/runtime.rb', line 8

def terminated
  @terminated
end

#timeObject (readonly)

Returns the value of attribute time.



8
9
10
# File 'lib/l43_rmap/runtime.rb', line 8

def time
  @time
end

Instance Method Details

#imageObject



27
# File 'lib/l43_rmap/runtime.rb', line 27

def image = chunks.map(&:image).join("\n")

#random_hexObject



23
# File 'lib/l43_rmap/runtime.rb', line 23

def random_hex =  @__randomhex__ ||= SecureRandom.hex

#random_rdObject



25
# File 'lib/l43_rmap/runtime.rb', line 25

def random_rd =  @__randomrd__ ||= (format "%04d", SecureRandom.random_number(DefaultDecRandomMax))

#run(input, output) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/l43_rmap/runtime.rb', line 12

def run(input, output)
  @output_stream = make_output_stream(output)
  @input_stream = make_input_stream(input)
  # @rand = SecureRandom.random_number
  @time = Time.now
  # p(time1: time.to_f)

  execute!
rescue EOFError 
end

#terminate!Object



29
# File 'lib/l43_rmap/runtime.rb', line 29

def terminate! = @terminated = true

#timestamp(base, mult: 1_000, now: nil) ⇒ Object



31
32
33
34
35
# File 'lib/l43_rmap/runtime.rb', line 31

def timestamp(base, mult: 1_000, now: nil)
  # p(time2: time.to_f)
  now ||= time
  (now.to_f * mult).to_i.to_s(base)
end