Class: Code::Node::Base2

Inherits:
Code::Node show all
Defined in:
lib/code/node/base_2.rb

Instance Method Summary collapse

Methods inherited from Code::Node

#resolve

Constructor Details

#initialize(parsed) ⇒ Base2

Returns a new instance of Base2.



6
7
8
9
# File 'lib/code/node/base_2.rb', line 6

def initialize(parsed)
  return if parsed.blank?
  @base_2 = parsed.presence
end

Instance Method Details

#evaluate(**_args) ⇒ Object



11
12
13
# File 'lib/code/node/base_2.rb', line 11

def evaluate(**_args)
  @base_2 ? Object::Integer.new(@base_2.to_i(2)) : Object::Nothing.new
end