Sha256: 6622ba932e064e1c0e4d00652314222d8d46342df934db7964af4e675e00633e

Contents?: true

Size: 880 Bytes

Versions: 29

Compression:

Stored size: 880 Bytes

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2019 Eric Crane.  All rights reserved.
#
# An Operator; part of an expression.
# A static helper class.
#

module Gloo
  module Core
    class Op

      #
      # Is the token an operator?
      #
      def self.op?( token )
        return [ '+', '-', '*', '/' ].include?( token.strip )
      end

      #
      # Create the operator for the given token.
      #
      def self.create_op( token )
        return Gloo::Expr::OpMinus.new if token == '-'
        return Gloo::Expr::OpMult.new if token == '*'
        return Gloo::Expr::OpDiv.new if token == '/'
        return Gloo::Expr::OpPlus.new if token == '+'

        return default_op
      end

      #
      # Get the default operator (+).
      #
      def self.default_op
        return Gloo::Expr::OpPlus.new
      end

    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
gloo-3.5.0 lib/gloo/core/op.rb
gloo-3.4.1 lib/gloo/core/op.rb
gloo-3.4.0 lib/gloo/core/op.rb
gloo-3.3.0 lib/gloo/core/op.rb
gloo-3.2.0 lib/gloo/core/op.rb
gloo-3.1.1 lib/gloo/core/op.rb
gloo-3.1.0 lib/gloo/core/op.rb
gloo-3.0.1 lib/gloo/core/op.rb
gloo-3.0.0 lib/gloo/core/op.rb
gloo-2.5.0 lib/gloo/core/op.rb
gloo-2.4.3 lib/gloo/core/op.rb
gloo-2.4.2 lib/gloo/core/op.rb
gloo-2.4.1 lib/gloo/core/op.rb
gloo-2.4.0 lib/gloo/core/op.rb
gloo-2.3.1 lib/gloo/core/op.rb
gloo-2.2.0 lib/gloo/core/op.rb
gloo-2.1.0 lib/gloo/core/op.rb
gloo-2.0.2 lib/gloo/core/op.rb
gloo-2.0.1 lib/gloo/core/op.rb
gloo-2.0.0 lib/gloo/core/op.rb