Class: Rubu::Move

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

Overview

Move is the action in Step.

Direct Known Subclasses

RubyCommand, ShellCommand, Step, Trail

Constant Summary collapse

@@host =
[]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMove

Returns a new instance of Move



76
77
78
79
80
81
82
# File 'lib/rubu.rb', line 76

def initialize
    @status = :success
    @errmsg = nil
    @output = nil

    @subs = []
end

Instance Attribute Details

#errmsgObject (readonly)

Storage for error message.



68
69
70
# File 'lib/rubu.rb', line 68

def errmsg
  @errmsg
end

#outputObject (readonly)

Command output.



71
72
73
# File 'lib/rubu.rb', line 71

def output
  @output
end

#statusObject (readonly)

Status after execution.



65
66
67
# File 'lib/rubu.rb', line 65

def status
  @status
end

#subsObject (readonly)

Sub actions.



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

def subs
  @subs
end

Instance Method Details

#display(msg) ⇒ Object

Display command output.



117
118
119
120
# File 'lib/rubu.rb', line 117

def display( msg )
    @output = msg
    STDOUT.puts @output
end

#error(msg) ⇒ Object

Report (and store) error.



106
107
108
109
# File 'lib/rubu.rb', line 106

def error( msg )
    @errmsg = msg
    STDERR.puts "Rubu Error: #{@errmsg}"
end

#hostObject

Current host.



101
102
103
# File 'lib/rubu.rb', line 101

def host
    @@host[-1]
end

#host_inObject

Push host as current to host stack.



91
92
93
# File 'lib/rubu.rb', line 91

def host_in
    @@host.push self
end

#host_outObject

Pop host from host stack.



96
97
98
# File 'lib/rubu.rb', line 96

def host_out
    @@host.pop
end

#useObject

Register Move to host (upper level).



85
86
87
88
# File 'lib/rubu.rb', line 85

def use
    host.subs.push( self ) if host
    self
end

#warn(msg) ⇒ Object

Report warning.



112
113
114
# File 'lib/rubu.rb', line 112

def warn( msg )
    STDERR.puts "Rubu Warning: #{msg}"
end