Module: Chamomile::Application

Includes:
Commands, Model, ViewDSL
Defined in:
lib/chamomile/application.rb

Overview

Primary mixin for Chamomile applications. Combines Model + Commands and provides a declarative callback DSL for handling events.

class Counter
include Chamomile::Application

def initialize
  @count = 0
end

on_key(:up, "k")  { @count += 1 }
on_key(:down, "j") { @count -= 1 }
on_key("q")        { quit }

def view
  "Count: #{@count}"
end
end

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ViewDSL

#horizontal, #list, #panel, #raw, #spinner, #status_bar, #table, #text, #vertical

Methods included from Commands

batch, cancel, cancellable, clear_screen, cmd, cursor_position, cursor_shape, deliver, disable_bracketed_paste, disable_mouse, disable_report_focus, enable_bracketed_paste, enable_mouse_all_motion, enable_mouse_cell_motion, enable_report_focus, enter_alt_screen, every, exec, exit_alt_screen, hide_cursor, map, none, parallel, println, quit, request_window_size, sequence, serial, shell, show_cursor, stream, tick, timer, window_title

Methods included from Model

#on_start, #start, #view, #with

Class Method Details

.included(base) ⇒ Object



30
31
32
# File 'lib/chamomile/application.rb', line 30

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#update(msg) ⇒ Object

Default update that dispatches to DSL-registered handlers. If a class defines its own update(msg), that takes precedence over this (standard Ruby MRO).



37
38
39
# File 'lib/chamomile/application.rb', line 37

def update(msg)
  self.class._dispatch_event(self, msg)
end