Class: Datatable::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/datatable/runner.rb

Constant Summary collapse

MESSAGE =
"      ___           ___         ___                     ___           ___
      /  /\         /  /\       /  /\        ___        /  /\         /  /\
     /  /::\       /  /::\     /  /::\      /  /\      /  /:/_       /  /:/
    /  /:/\:\     /  /:/\:\   /  /:/\:\    /  /:/     /  /:/ /\     /  /:/
   /  /:/~/::\   /  /:/~/:/  /  /:/~/:/   /  /:/     /  /:/ /:/_   /  /:/  ___
  /__/:/ /:/\:\ /__/:/ /:/  /__/:/ /:/   /  /::\    /__/:/ /:/ /\ /__/:/  /  /\
  \  \:\/:/__\/ \  \:\/:/   \  \:\/:/   /__/:/\:\   \  \:\/:/ /:/ \  \:\ /  /:/
   \  \::/       \  \::/     \  \::/    \__\/  \:\   \  \::/ /:/   \  \:\  /:/
    \  \:\        \  \:\      \  \:\         \  \:\   \  \:\/:/     \  \:\/:/
     \  \:\        \  \:\      \  \:\         \__\/    \  \::/       \  \::/
      \__\/         \__\/       \__\/                   \__\/         \__\/


      https://datatables.net/
Add advanced interaction controls to your HTML tables the free & easy way \n
\n
\n
Example: \n
datatable g model_name"
ERROR_MESSAGE =
'USAGE: datatable up APP_NAME'

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Runner

Returns a new instance of Runner.



25
26
27
# File 'lib/datatable/runner.rb', line 25

def initialize(options)
  @options = options
end

Instance Method Details

#executeObject

Raises:



29
30
31
32
33
# File 'lib/datatable/runner.rb', line 29

def execute
  raise MESSAGE if @options[0] == 'h'
  raise ERROR_MESSAGE unless valid?
  Datatable::Generator.new(@options[1]).up
end

#valid?Boolean

Returns:

  • (Boolean)


35
36
37
38
39
# File 'lib/datatable/runner.rb', line 35

def valid?
  # first option should always be up
  return false if @options[0] != 'g'
  true
end