Module: Pwnlib::Constants
- Extended by:
- Context
- Defined in:
- lib/pwnlib/constants/constants.rb,
lib/pwnlib/constants/constant.rb
Overview
Module containing constants.
Defined Under Namespace
Classes: Constant, ConstantBuilder
Class Method Summary collapse
-
.eval(str) ⇒ Constant
Eval for Constants.
-
.method_missing(method, *args, &block) ⇒ Constant
To support getting constants like
Pwnlib::Constants.SYS_read
. - .respond_to_missing?(method, _include_all) ⇒ Boolean
Class Method Details
.eval(str) ⇒ Constant
Eval for Constants.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pwnlib/constants/constants.rb', line 52 def eval(str) return str unless str.instance_of?(String) begin val = calculator.evaluate!(str.strip).to_i rescue Dentaku::UnboundVariableError => e raise ::Pwnlib::Errors::ConstantNotFoundError, "Undefined constant(s): #{e.unbound_variables.join(', ')}" end ::Pwnlib::Constants::Constant.new("(#{str})", val) end |
.method_missing(method, *args, &block) ⇒ Constant
To support getting constants like Pwnlib::Constants.SYS_read
.
24 25 26 |
# File 'lib/pwnlib/constants/constants.rb', line 24 def method_missing(method, *args, &block) args.empty? && block.nil? && get_constant(method) || super end |
.respond_to_missing?(method, _include_all) ⇒ Boolean
29 30 31 |
# File 'lib/pwnlib/constants/constants.rb', line 29 def respond_to_missing?(method, _include_all) !get_constant(method).nil? end |