Class: SatoriLikeDictionary::TemplateContext
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- SatoriLikeDictionary::TemplateContext
- Defined in:
- lib/satori_like_dictionary.rb
Overview
template runtime context class
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#call_to(target_character) ⇒ Object
set communication target.
-
#change_scope ⇒ Object
change character scope.
-
#initialize(events, request) ⇒ TemplateContext
constructor
initialize context.
-
#jump_to(target_entry) ⇒ Object
jump to entry.
-
#method_missing(method_name, *args) ⇒ Object
method_missing.
Constructor Details
#initialize(events, request) ⇒ TemplateContext
initialize context
247 248 249 250 |
# File 'lib/satori_like_dictionary.rb', line 247 def initialize(events, request) @events = events @request = request end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
method_missing
272 273 274 275 276 277 278 |
# File 'lib/satori_like_dictionary.rb', line 272 def method_missing(method_name, *args) if result = method_name.match(/^r(\d+)$/) # r0 -> request.Reference0 request["Reference#{result[1]}"] else super end end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
242 243 244 |
# File 'lib/satori_like_dictionary.rb', line 242 def events @events end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
242 243 244 |
# File 'lib/satori_like_dictionary.rb', line 242 def request @request end |
Instance Method Details
#call_to(target_character) ⇒ Object
set communication target
267 268 269 |
# File 'lib/satori_like_dictionary.rb', line 267 def call_to(target_character) request.__satori_target_character = target_character end |
#change_scope ⇒ Object
change character scope
253 254 255 256 257 |
# File 'lib/satori_like_dictionary.rb', line 253 def change_scope scope_info = "__satori_scope_#{self.object_id}" request[scope_info] = request[scope_info].nil? || request[scope_info] == 1 ? 0 : 1 '\\' + request[scope_info].to_s end |
#jump_to(target_entry) ⇒ Object
jump to entry
261 262 263 |
# File 'lib/satori_like_dictionary.rb', line 261 def jump_to(target_entry) "(#{target_entry})\\e" end |