Class: JLDrill::PromptContext

Inherits:
Context::Context show all
Defined in:
lib/jldrill/contexts/PromptContext.rb

Direct Known Subclasses

PromptForDeleteContext, PromptForSaveContext

Defined Under Namespace

Classes: PromptView

Instance Attribute Summary collapse

Attributes inherited from Context::Context

#mainView, #parent, #viewBridge

Instance Method Summary collapse

Methods inherited from Context::Context

#addView, #exit, #isEntered?, #onExit, #peekAtView, #setupViews

Constructor Details

#initialize(viewBridge) ⇒ PromptContext

Returns a new instance of PromptContext.



12
13
14
15
16
17
18
19
20
# File 'lib/jldrill/contexts/PromptContext.rb', line 12

def initialize(viewBridge)
	super(viewBridge)
       @cancel = "cancel"
       @yes = "yes"
       @no = "no"
	@response = @cancel
          @title = "Prompt"
          @message = "Please replace this with a question for the user."
end

Instance Attribute Details

#cancelObject (readonly)

Returns the value of attribute cancel.



10
11
12
# File 'lib/jldrill/contexts/PromptContext.rb', line 10

def cancel
  @cancel
end

#messageObject (readonly)

Returns the value of attribute message.



10
11
12
# File 'lib/jldrill/contexts/PromptContext.rb', line 10

def message
  @message
end

#noObject (readonly)

Returns the value of attribute no.



10
11
12
# File 'lib/jldrill/contexts/PromptContext.rb', line 10

def no
  @no
end

#responseObject (readonly)

Returns the value of attribute response.



10
11
12
# File 'lib/jldrill/contexts/PromptContext.rb', line 10

def response
  @response
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'lib/jldrill/contexts/PromptContext.rb', line 10

def title
  @title
end

#yesObject (readonly)

Returns the value of attribute yes.



10
11
12
# File 'lib/jldrill/contexts/PromptContext.rb', line 10

def yes
  @yes
end

Instance Method Details

#createViewsObject

The concrete class should override this method



44
45
46
47
48
# File 'lib/jldrill/contexts/PromptContext.rb', line 44

def createViews
    # Please set the title and message member variables
    # and call super() in the concrete class
    		@mainView = @viewBridge.PromptView.new(self, @title, @message)
end

#destroyViewsObject



50
51
52
53
# File 'lib/jldrill/contexts/PromptContext.rb', line 50

def destroyViews
    @mainView.destroy if !@mainView.nil?
    @mainView = nil
end

#enter(parent) ⇒ Object



55
56
57
58
59
60
# File 'lib/jldrill/contexts/PromptContext.rb', line 55

def enter(parent)
    super(parent)
  		@response = @mainView.run
  		self.exit
  		return @response
end