Skip to content

Workaround for distance option issue starting from TUI #377

@rona1707

Description

@rona1707

Hello,

I got the following error by starting from TUI.

geotoad.rb:186:in 'GeoToad#getoptions': undefined method '=~' for an instance of Integer (NoMethodError)

So I'm not so familiar wih ruby, but at least I'm into software development. So I asked the AI:

This means Ruby is trying to use the =~ operator (used for regex matching) on an integer, but =~ only works on strings.

``

# distanceMax from command line can contain the unit
@distanceMax       = @option['distanceMax'].to_f
if @distanceMax == 0.0
  @distanceMax = 10
end
if @option['distanceMax'] =~ /(mi|km)/
  @useMetric     = ($1 == "km" || nil)
  # else leave usemetric unchanged
end

I'm not familiar with the type of distanceMax in the @options but it seems like some type error.
The recommended solution was to convert the @option['distanceMax'] to a string, which worked for me.

# distanceMax from command line can contain the unit
@distanceMax       = @option['distanceMax'].to_f
if @distanceMax == 0.0
  @distanceMax = 10
end
if @option['distanceMax'].to_s =~ /(mi|km)/
  @useMetric     = ($1 == "km" || nil)
  # else leave usemetric unchanged
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions