Class: SorobanRustBackend::Common::InputInterpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/common/input_interpreter.rb

Overview

This class is responsible for interpreting the input string.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ InputInterpreter

Returns a new instance of InputInterpreter.



5
6
7
# File 'lib/common/input_interpreter.rb', line 5

def initialize(input)
  @input = input
end

Class Method Details

.interpret(input) ⇒ Object



9
10
11
# File 'lib/common/input_interpreter.rb', line 9

def self.interpret(input)
  new(input).interpret
end

Instance Method Details

#interpretObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/common/input_interpreter.rb', line 13

def interpret
  if number?(@input)
    number_return(@input)
  elsif string?(@input)
    string_return(@input)
  elsif boolean?(@input)
    boolean_return(@input)
  else
    variable_return(@input)
  end
end