Sha256: d3656c7ba8314ac4e8bf77b998871551fc3b002dc5b96ff31dfbd9b73b76f221
Contents?: true
Size: 562 Bytes
Versions: 3
Compression:
Stored size: 562 Bytes
Contents
# frozen_string_literal: true require_relative 'statement' module Basic101 class IfStatement < Statement attr_writer :else_statement def initialize(condition) @condition = condition @true_statement = nil end def end_statement=(statement) @else_statement.end_statement = statement end def execute(runtime) if @condition.eval(runtime).to_f == 0 @else_statement.goto_following_statement(runtime) end end protected def state [@condition, @true_statement] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
basic101-1.0.2 | lib/basic101/if_statement.rb |
basic101-1.0.1 | lib/basic101/if_statement.rb |
basic101-1.0.0 | lib/basic101/if_statement.rb |