Class: Zubat::RubyCode

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

Instance Method Summary collapse

Constructor Details

#initialize(code:) ⇒ RubyCode

Returns a new instance of RubyCode.



5
6
7
# File 'lib/zubat/ruby_code.rb', line 5

def initialize(code:)
  @code = code
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
# File 'lib/zubat/ruby_code.rb', line 9

def valid?
  RubyVM::InstructionSequence.compile(@code)

  true
rescue SyntaxError
  false
end