Class: Mousevc::App

Inherits:
Object
  • Object
show all
Defined in:
lib/mousevc/app.rb

Overview

true The top level class of Mousevc. The container for all of the objects created within a Mousevc application.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ App

Creates a new Mousevc::App instance

Parameters:

  • options (Hash) (defaults to: {})

    expects the following keys:

    • :controller => [String] name of default controller class

    • :model => [String] name of default model class

    • :action => [Symbol] method to call on default controller

    • :views => [String] relative path to views directory

    • :looping => [Boolean] true if the application should loop, defaults to false

    • :system_clear => [Boolean] true if output should be cleared on update, defaults to false


45
46
47
48
49
50
51
52
# File 'lib/mousevc/app.rb', line 45

def initialize(options={})
	@controller = options[:controller]
	@model = options[:model]
	@action = options[:action]
	@views = options[:views]
	@looping = options[:looping].nil? ? false : options[:looping]
	@system_clear = options[:system_clear].nil? ? false : options[:system_clear]
end

Instance Attribute Details

#loopingBoolean

Set this to true if you want the application to loop, defaults to false

Returns:

  • (Boolean)

    whether or not the application should loop


32
33
34
# File 'lib/mousevc/app.rb', line 32

def looping
  @looping
end

#system_clearBoolean

Setting this to false will disable calls to system('clear') at the start of each application loop.

Returns:

  • (Boolean)

    whether or not to perform system clear


23
24
25
# File 'lib/mousevc/app.rb', line 23

def system_clear
  @system_clear
end

Instance Method Details

#looping?Boolean

Returns true if @looping is set to true

Returns:

  • (Boolean)

74
75
76
# File 'lib/mousevc/app.rb', line 74

def looping?
	@looping
end

#runObject

Run the application


57
58
59
60
# File 'lib/mousevc/app.rb', line 57

def run
	reset
	@looping ? listen : single
end

#system_clear?Boolean

Returns true if @system_clear is true

Returns:

  • (Boolean)

    whether or not system clearing is enabled


67
68
69
# File 'lib/mousevc/app.rb', line 67

def system_clear?
	@system_clear
end