Exception: Subaltern::Command

Inherits:
StandardError
  • Object
show all
Defined in:
lib/subaltern/evaluator.rb

Overview

A command like ‘break’ or ‘next’.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, args) ⇒ Command

Returns a new instance of Command.



156
157
158
159
# File 'lib/subaltern/evaluator.rb', line 156

def initialize(name, args)
  @name = name
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



154
155
156
# File 'lib/subaltern/evaluator.rb', line 154

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



154
155
156
# File 'lib/subaltern/evaluator.rb', line 154

def name
  @name
end

Class Method Details

.narrow(o) ⇒ Object

Used to circumvent a difference between ruby 1.8 and 1.9…



172
173
174
175
176
177
# File 'lib/subaltern/evaluator.rb', line 172

def self.narrow(o)

  return o.result if o.is_a?(Command)
  return o.collect { |e| e.is_a?(Command) ? e.result : e } if o.is_a?(Array)
  o
end

Instance Method Details

#resultObject

Used by Command.narrow



163
164
165
166
167
168
# File 'lib/subaltern/evaluator.rb', line 163

def result

  return nil if args.empty?
  return @args.first if args.size == 1
  @args
end