Module: Repop::InstanceMethods
- Defined in:
- lib/repop/repopable.rb
Instance Method Summary collapse
- #replace(text) ⇒ Object
- #repop_regexp ⇒ Object
- #repop_value ⇒ Object
- #repop_world_regexp ⇒ Object
- #repop_world_value ⇒ Object
- #repopable? ⇒ Boolean
- #world_replace(text) ⇒ Object
Instance Method Details
#replace(text) ⇒ Object
16 17 18 |
# File 'lib/repop/repopable.rb', line 16 def replace(text) return text.gsub(repop_regexp, repop_value) end |
#repop_regexp ⇒ Object
19 20 21 22 23 24 |
# File 'lib/repop/repopable.rb', line 19 def repop_regexp local = self.class.repop_local.map{|a| "{#{a.to_s}}"} repops = self.repops.map{|o| o.tkey} tkeys = local + repops return Regexp.new("(#{tkeys.join('|')})") end |
#repop_value ⇒ Object
25 26 27 |
# File 'lib/repop/repopable.rb', line 25 def repop_value return Hash[self.class.repop_local.map{|o| ["{#{o.to_s}}",send(o)]} + self.repops.map{|o| [o.tkey,o.value]}] end |
#repop_world_regexp ⇒ Object
31 32 33 34 35 36 |
# File 'lib/repop/repopable.rb', line 31 def repop_world_regexp local = self.class.repop_local.map{|a| a.to_s} repops = self.repops.map{|o| o.key} keys = local + repops return Regexp.new("(#{keys.join('|')})\\b") end |
#repop_world_value ⇒ Object
37 38 39 |
# File 'lib/repop/repopable.rb', line 37 def repop_world_value return Hash[self.class.repop_local.map{|o| [o.to_s,send(o)]} + self.repops.map{|o| [o.key,o.value]}] end |
#repopable? ⇒ Boolean
13 14 15 |
# File 'lib/repop/repopable.rb', line 13 def repopable? return true end |
#world_replace(text) ⇒ Object
28 29 30 |
# File 'lib/repop/repopable.rb', line 28 def world_replace(text) return text.gsub(repop_world_regexp, repop_world_value) end |