Class: AskChatgpt::Helpers::DummyInputMethod

Inherits:
IRB::InputMethod
  • Object
show all
Defined in:
lib/ask_chatgpt/helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list = []) ⇒ DummyInputMethod

Returns a new instance of DummyInputMethod.



29
30
31
32
33
# File 'lib/ask_chatgpt/helpers.rb', line 29

def initialize(list = [])
  super("test")
  @line_no = 0
  @list = list
end

Instance Attribute Details

#line_noObject (readonly)

Returns the value of attribute line_no.



27
28
29
# File 'lib/ask_chatgpt/helpers.rb', line 27

def line_no
  @line_no
end

#listObject (readonly)

Returns the value of attribute list.



27
28
29
# File 'lib/ask_chatgpt/helpers.rb', line 27

def list
  @list
end

Instance Method Details

#encodingObject



43
44
45
# File 'lib/ask_chatgpt/helpers.rb', line 43

def encoding
  Encoding.default_external
end

#eof?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ask_chatgpt/helpers.rb', line 39

def eof?
  @line_no >= @list.size
end

#getsObject



35
36
37
# File 'lib/ask_chatgpt/helpers.rb', line 35

def gets
  @list[@line_no]&.tap {@line_no += 1}
end

#resetObject



47
48
49
# File 'lib/ask_chatgpt/helpers.rb', line 47

def reset
  @line_no = 0
end