Class: NOMS::Command::Window

Inherits:
Base
  • Object
show all
Defined in:
lib/noms/command/window.rb

Defined Under Namespace

Classes: Console, Location

Instance Attribute Summary collapse

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Base

#default_logger

Constructor Details

#initialize(invoker = $0, origin = nil, opt = {}) ⇒ Window

Returns a new instance of Window.



22
23
24
25
26
27
28
29
# File 'lib/noms/command/window.rb', line 22

def initialize(invoker=$0, origin=nil, opt={})
    @document = nil
    @origin = origin
    @name = invoker
    @log = opt[:logger] || default_logger
    @console = NOMS::Command::Window::Console.new(@log)
    @location = NOMS::Command::Window::Location.new(self)
end

Instance Attribute Details

#consoleObject (readonly)

Returns the value of attribute console.



20
21
22
# File 'lib/noms/command/window.rb', line 20

def console
  @console
end

#documentObject

Returns the value of attribute document.



19
20
21
# File 'lib/noms/command/window.rb', line 19

def document
  @document
end

#locationObject (readonly)

Returns the value of attribute location.



20
21
22
# File 'lib/noms/command/window.rb', line 20

def location
  @location
end

#nameObject

Returns the value of attribute name.



19
20
21
# File 'lib/noms/command/window.rb', line 19

def name
  @name
end

#originObject

Returns the value of attribute origin.



19
20
21
# File 'lib/noms/command/window.rb', line 19

def origin
  @origin
end

Instance Method Details

#alert(msg) ⇒ Object



35
36
37
# File 'lib/noms/command/window.rb', line 35

def alert(msg)
    @log.error msg
end

#isattyObject



31
32
33
# File 'lib/noms/command/window.rb', line 31

def isatty()
    $stdout.tty?
end

#prompt(prompt_text, echo = true) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/noms/command/window.rb', line 39

def prompt(prompt_text, echo=true)
    echo = true if echo.nil?
    @log.debug "prompt(#{prompt_text.inspect}, #{echo.inspect})"
    v = ask(prompt_text) { |p| p.echo = false unless echo }
    @log.debug "-> #{v}"
    v
end