Class: TermuxRubyApi::SubSystems::Dialog

Inherits:
Base
  • Object
show all
Defined in:
lib/termux_ruby_api/sub_systems/dialog.rb

Instance Attribute Summary

Attributes inherited from Base

#owner

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from TermuxRubyApi::SubSystems::Base

Instance Method Details

#checkbox(title = nil, result_type: :index, options:) ⇒ Array

Shows a dialog asking for a multiple choice question, with checkboxes



40
41
42
43
44
45
46
47
48
# File 'lib/termux_ruby_api/sub_systems/dialog.rb', line 40

def checkbox(title = nil, result_type: :index, options:)
  args = owner.generate_args_list([['checkbox'],
                                   ['-t', title],
                                   ['-v', options.join(',')]
                                  ])
  res = owner.json_api_command('dialog', nil, *args)
  return res if result_type == :raw
  res[:values]&.map { |r| extract_result(r, result_type) }
end

#confirm(title = nil, hint: nil, result_type: :boolean) ⇒ Object

Shows a dialog asking for a Yes/No confirmation



24
25
26
27
28
29
30
# File 'lib/termux_ruby_api/sub_systems/dialog.rb', line 24

def confirm(title = nil, hint: nil, result_type: :boolean)
  args = owner.generate_args_list([['confirm'],
                                   ['-t', title],
                                   ['-i', hint]
                                  ])
  single_result(args, result_type)
end

#date(title = nil, result_type: :date) ⇒ Object

Shows a dialog asking for a calendar date



83
84
85
86
87
88
# File 'lib/termux_ruby_api/sub_systems/dialog.rb', line 83

def date(title = nil, result_type: :date)
  args = owner.generate_args_list([['date'],
                                   ['-t', title]
                                  ])
  single_result(args, result_type)
end

#radio(title = nil, result_type: :index, options:) ⇒ Object Also known as: spinner, sheet

Shows a dialog asking for a multiple choice question, with radio buttons



58
59
60
61
62
63
64
# File 'lib/termux_ruby_api/sub_systems/dialog.rb', line 58

def radio(title = nil, result_type: :index, options:)
  args = owner.generate_args_list([[__callee__.to_s],
                                   ['-t', title],
                                   ['-v', options.join(',')]
                                  ])
  single_result(args, result_type)
end

#speech(title = nil, hint: nil, result_type: :text) ⇒ Object

Shows a dialog asking for spoken input, to be converted to text



97
98
99
100
101
102
103
# File 'lib/termux_ruby_api/sub_systems/dialog.rb', line 97

def speech(title = nil, hint: nil, result_type: :text)
  args = owner.generate_args_list([['speech'],
                                   ['-t', title],
                                   ['-i', hint]
                                  ])
  single_result(args, result_type)
end

#text(title = nil, hint: nil) ⇒ String

Shows a dialog asking for a simple text message



8
9
10
11
12
13
14
# File 'lib/termux_ruby_api/sub_systems/dialog.rb', line 8

def text(title = nil, hint: nil)
  args = owner.generate_args_list([['text'],
                                   ['-t', title],
                                   ['-i', hint]
                                  ])
  single_result(args, :text)
end