Class: Fatty::InputSession

Inherits:
Session
  • Object
show all
Defined in:
lib/fatty/session/input_session.rb

Instance Attribute Summary collapse

Attributes inherited from Session

#counter, #keymap, #terminal, #views

Instance Method Summary collapse

Methods inherited from Session

#add_view, #close, #handle_resize, #init, #inspect, #persist!, #resolve_action, #tick, #update, #view

Methods included from Actionable

included

Constructor Details

#initialize(field:, keymap:, views: [], on_accept: nil) ⇒ InputSession

Returns a new instance of InputSession.

Parameters:

  • on_accept: (defaults to: nil)

    ->(line, session, terminal) { ... }



8
9
10
11
12
# File 'lib/fatty/session/input_session.rb', line 8

def initialize(field:, keymap:, views: [], on_accept: nil)
  super(keymap: keymap, views: views)
  @field = field
  @on_accept = on_accept
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



5
6
7
# File 'lib/fatty/session/input_session.rb', line 5

def field
  @field
end

Instance Method Details

#keymap_contextsObject

Framework and Session Hooks



18
19
20
21
22
23
24
# File 'lib/fatty/session/input_session.rb', line 18

def keymap_contexts
  if paging_mode?
    [:paging, :text, :terminal]
  else
    [:text, :terminal]
  end
end