Class: Fatty::CallbackEnvironment
- Inherits:
-
Object
- Object
- Fatty::CallbackEnvironment
- Includes:
- AlertApi, ChooseApi, EnvironmentApi, KeytestApi, MenuApi, OutputApi, ProgressApi, PromptApi, StatusApi
- Defined in:
- lib/fatty/callback_environment.rb
Constant Summary collapse
- INTERRUPT_POLL_INTERVAL =
1.0
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
-
#terminal ⇒ Object
readonly
Returns the value of attribute terminal.
Instance Method Summary collapse
- #check_interrupt! ⇒ Object
-
#initialize(terminal:, output_id:, label: nil) ⇒ CallbackEnvironment
constructor
A new instance of CallbackEnvironment.
- #queue(command) ⇒ Object
Methods included from EnvironmentApi
Methods included from KeytestApi
Methods included from AlertApi
Methods included from StatusApi
#error, #good, #info, #oops, #status, #warn
Methods included from PromptApi
Methods included from ChooseApi
#choose, #choose_multi, #confirm
Methods included from ProgressApi
Methods included from MenuApi
Methods included from OutputApi
#append, #append_now, #markdown
Constructor Details
#initialize(terminal:, output_id:, label: nil) ⇒ CallbackEnvironment
Returns a new instance of CallbackEnvironment.
35 36 37 38 39 40 41 |
# File 'lib/fatty/callback_environment.rb', line 35 def initialize(terminal:, output_id:, label: nil) @terminal = terminal @output_id = output_id @label = label @commands = [] @last_interrupt_check_at = nil end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
33 34 35 |
# File 'lib/fatty/callback_environment.rb', line 33 def commands @commands end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
33 34 35 |
# File 'lib/fatty/callback_environment.rb', line 33 def label @label end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
33 34 35 |
# File 'lib/fatty/callback_environment.rb', line 33 def payload @payload end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
33 34 35 |
# File 'lib/fatty/callback_environment.rb', line 33 def progress @progress end |
#terminal ⇒ Object (readonly)
Returns the value of attribute terminal.
33 34 35 |
# File 'lib/fatty/callback_environment.rb', line 33 def terminal @terminal end |
Instance Method Details
#check_interrupt! ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fatty/callback_environment.rb', line 48 def check_interrupt! now = monotonic_time if interrupt_check_due?(now) @last_interrupt_check_at = now raise Fatty::Interrupt if terminal.interrupt_pending? end nil end |
#queue(command) ⇒ Object
43 44 45 46 |
# File 'lib/fatty/callback_environment.rb', line 43 def queue(command) @commands << command command end |