Class: Glib::Json::NewDynamicText::TextSpec
- Inherits:
-
Struct
- Object
- Struct
- Glib::Json::NewDynamicText::TextSpec
- Defined in:
- app/controllers/concerns/glib/json/new_dynamic_text.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#prop ⇒ Object
Returns the value of attribute prop.
-
#view ⇒ Object
Returns the value of attribute view.
Instance Method Summary collapse
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
107 108 109 |
# File 'app/controllers/concerns/glib/json/new_dynamic_text.rb', line 107 def args @args end |
#prop ⇒ Object
Returns the value of attribute prop
107 108 109 |
# File 'app/controllers/concerns/glib/json/new_dynamic_text.rb', line 107 def prop @prop end |
#view ⇒ Object
Returns the value of attribute view
107 108 109 |
# File 'app/controllers/concerns/glib/json/new_dynamic_text.rb', line 107 def view @view end |
Instance Method Details
#substitute_image_with(images) ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'app/controllers/concerns/glib/json/new_dynamic_text.rb', line 112 def substitute_image_with(images) view[prop] = view[prop].gsub(/\{\{image(\d)\}\}/) { if image = images[$1.to_i - 1] ApplicationController.helpers.glib_dynamic_image_url(image.blob.key) else "{{image#{$1}}}" end } end |
#substitute_with(text) ⇒ Object
108 109 110 |
# File 'app/controllers/concerns/glib/json/new_dynamic_text.rb', line 108 def substitute_with(text) view[prop] = text.gsub(/\{\{(\w+)\}\}/) { args.fetch($1, "{{#{$1}}}") } end |