lib/flea/environment.rb in flea-0.1.0 vs lib/flea/environment.rb in flea-0.1.1

- old
+ new

@@ -1,38 +1,40 @@ +# frozen_string_literal: true + module Flea class Environment - - attr_accessor :parent - + attr_accessor :parent, :table + def initialize(parent = nil) @parent = parent @table = {} add_globals if @parent.nil? end - + def has_variable?(name) - return true if @table.has_key?(name) + return true if @table.key?(name) return false if @parent.nil? - return @parent.has_variable?(name) + + @parent.has_variable?(name) end - + def find(name) - return @table[name] if @table.has_key?(name) + return @table[name] if @table.key?(name) return nil if @parent.nil? - return @parent.find(name) + + @parent.find(name) end - + def define(name, value) @table[name] = value end - + private - + def add_globals - @table.merge!({ - :"#t" => true, - :"#f" => false - }) + @table.merge!( + '#t': true, + '#f': false + ) end - end -end \ No newline at end of file +end