class Gamefic::Props::Output
A container for output sent to players with a hash interface for custom data.
Constants
- READER_METHODS
- WRITER_METHODS
Attributes
raw_data[R]
Public Class Methods
new(**data)
click to toggle source
# File lib/gamefic/props/output.rb, line 14 def initialize **data @raw_data = { messages: '', options: [], queue: [], scene: {}, prompt: '' } merge! data end
Public Instance Methods
[](key)
click to toggle source
@param key [Symbol]
# File lib/gamefic/props/output.rb, line 62 def [] key raw_data[key] end
[]=(key, value)
click to toggle source
@param key [Symbol] @param value [Object]
# File lib/gamefic/props/output.rb, line 68 def []= key, value raw_data[key] = value end
freeze()
click to toggle source
Calls superclass method
# File lib/gamefic/props/output.rb, line 89 def freeze raw_data.freeze super end
merge!(data)
click to toggle source
# File lib/gamefic/props/output.rb, line 81 def merge! data data.each { |key, val| self[key] = val } end
method_missing(method, *args)
click to toggle source
Calls superclass method
# File lib/gamefic/props/output.rb, line 94 def method_missing method, *args return raw_data[method] if READER_METHODS.include?(method) return raw_data[method.to_s[0..-2].to_sym] = args.first if WRITER_METHODS.include?(method) super end
replace(data)
click to toggle source
# File lib/gamefic/props/output.rb, line 85 def replace data raw_data.replace data end
respond_to_missing?(method, _with_private = false)
click to toggle source
# File lib/gamefic/props/output.rb, line 102 def respond_to_missing?(method, _with_private = false) READER_METHODS.include?(method) || WRITER_METHODS.include?(method) end
to_hash()
click to toggle source
@return [Hash]
# File lib/gamefic/props/output.rb, line 73 def to_hash raw_data.dup end
to_json(_ = nil)
click to toggle source
# File lib/gamefic/props/output.rb, line 77 def to_json _ = nil raw_data.to_json end