Class: Jop

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_text) ⇒ Jop

Returns a new instance of Jop.



264
265
266
267
# File 'lib/jop.rb', line 264

def initialize command_text
  @command_text = command_text
  @tokens = Tokenizer.new(command_text).tokens.reverse
end

Instance Attribute Details

#tokensObject (readonly)

Returns the value of attribute tokens.



262
263
264
# File 'lib/jop.rb', line 262

def tokens
  @tokens
end

Instance Method Details

#advance(amount) ⇒ Object



269
270
271
# File 'lib/jop.rb', line 269

def advance amount
  @tokens = @tokens[amount...@tokens.length]
end

#eval_on(ary) ⇒ Object



273
274
275
276
277
278
279
# File 'lib/jop.rb', line 273

def eval_on ary
  result = ary
  while not @tokens.empty?
    result = eval_op(result)
  end
  result
end