Method: FloatString#fill

Defined in:
lib/carat/floatstring.rb

#fill(val, rng = 0..-1)) ⇒ Object



107
108
109
110
111
112
113
114
# File 'lib/carat/floatstring.rb', line 107

def fill(val, rng=0..-1)
  a = @float.to_a.sort_by{ |k,v| k }
  s = a.index( a.find{ |e| e[0] == rng.first.to_f } )
  f = a.index( a.find{ |e| e[0] == rng.last.to_f } )
  x = (rng.exclude_end? ? a[s...f] : a[s..f])
  x.each{ |k,v| @float[k] = val.to_s }
  self.to_s
end