Class: Amrita2::Runtime::Context

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream = "", old_context = nil, opt = {}) ⇒ Context

Returns a new instance of Context.



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/amrita2/core.rb', line 285

def initialize(stream="", old_context=nil, opt={})
  @sub_streams = {}
  if old_context
    @sub_streams = old_context.sub_streams if opt[:inherit_sub_streams]
    @main_stream = (stream or old_context.main_stream)
    @current_binding = (opt[:binding] or old_context.current_binding)
    @current_data = (opt[:data] or old_context.current_data)
    @mv_index = old_context.mv_index
  else
    @main_stream = (stream or "")
    @current_binding = TOPLEVEL_BINDING
    @current_data = nil
    @mv_index = {}
  end
end

Instance Attribute Details

#current_bindingObject

Returns the value of attribute current_binding.



283
284
285
# File 'lib/amrita2/core.rb', line 283

def current_binding
  @current_binding
end

#current_dataObject

Returns the value of attribute current_data.



283
284
285
# File 'lib/amrita2/core.rb', line 283

def current_data
  @current_data
end

#main_streamObject (readonly)

Returns the value of attribute main_stream.



282
283
284
# File 'lib/amrita2/core.rb', line 282

def main_stream
  @main_stream
end

#mv_indexObject (readonly)

Returns the value of attribute mv_index.



282
283
284
# File 'lib/amrita2/core.rb', line 282

def mv_index
  @mv_index
end

#sub_streamsObject (readonly)

Returns the value of attribute sub_streams.



282
283
284
# File 'lib/amrita2/core.rb', line 282

def sub_streams
  @sub_streams
end

Instance Method Details

#clear_substream(key) ⇒ Object



305
306
307
# File 'lib/amrita2/core.rb', line 305

def clear_substream(key)
  @sub_streams[key] = ""
end

#sub_stream(key) ⇒ Object



301
302
303
# File 'lib/amrita2/core.rb', line 301

def sub_stream(key)
  @sub_streams[key] ||= ""
end