Class: Simpler::Reply

Inherits:
String
  • Object
show all
Defined in:
lib/simpler/reply.rb

Constant Summary collapse

ONE_FLOAT_RE =
/] ([\w\.-]+)/o

Instance Method Summary collapse

Instance Method Details

#array_castObject



11
12
13
# File 'lib/simpler/reply.rb', line 11

def array_cast
  self.chomp.split("\n").rm_leader.split(" ")
end

#rm_leaderObject

removes the [1] from the line



7
8
9
# File 'lib/simpler/reply.rb', line 7

def rm_leader
  gsub(/^\[\d+\] /,'')
end

#to_sfObject

returns a single float. Assumes the answer takes the form: ā€œ[1] <Float>nā€ => Float



16
17
18
# File 'lib/simpler/reply.rb', line 16

def to_sf
  ONE_FLOAT_RE.match(self)[1].to_f
end