Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/opl.rb
Instance Method Summary collapse
Instance Method Details
#paren_to_array ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/opl.rb', line 45 def paren_to_array #in: "(2..5)" #out: "[2,3,4,5]" text = self start = text[1].to_i stop = text[-2].to_i (start..stop).map{|i|i}.to_s end |
#sub_paren_with_array ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/opl.rb', line 54 def sub_paren_with_array text = self targets = text.scan(/\([\d]+\.\.[\d]+\)/) targets.each do |target| text = text.gsub(target, target.paren_to_array) end return(text) end |