Writing Functions in Ruby Code Editor

  1. ALL code must be within a module. Usually a top level namespace module and then inside a specific extension submodule.
    (Ie, the toplevel of Ruby is Object, which is an ancestor of everything else, so you should not define methods at the top level as everyone else’s classes and modules will inherit them.)

  2. Do not ever use global variables (despite older poor examples that do.)
    Instead use @vars or @@vars within your modules | submodules for persistent references.
    Otherwise pass values as method parameters.

  3. Do not put a space between method name and the ( of it’s parameter list.
    This will cause warnings. (In a future Ruby version it mat result in a SyntaxError exception.)

  4. Please post code correctly in forum with tabs replaced with 2 space characters.

Something more like …

# encoding: UTF-8

module GardenLiving
  module Test

    extend self

    @counter_overhangF ||= 2.0
    @countertop_height ||= 34.0
    @countertop_thickness ||= 1.5
    @kickplate_height  ||= 3.0
    @start_verticle ||= 0

    def wrud(width, running_vertical)
      point1 = Geom::Point3d.new(
        running_vertical+width, @counter_overhangF, @kickplate_height
      )
      point2 = Geom::Point3d.new(
        running_vertical+width, @counter_overhangF,
        @countertop_height - @countertop_thickness
      )
      entities.add_line(point1, point2)
    end

    def test_command
      for running_vertical in @start_verticle..30
        wrud(width, running_vertical)
      end
    end

    if !defined?(@loaded)
      UI.menu("Plugins").add_item("GardenLiving - Test") {
        test_command()
      }
      @loaded = true
    end

  end # submodule
end # namespace module

forin looping statement is only one of the iterative staements. See …
File: control_expressions.rdoc [Ruby 2.7.1]

There are also many built-in iterator methods for the Ruby Array class (which also has the Enumerable module mixed in.)