Class: Lich::Common::StringProc
- Inherits:
-
Object
- Object
- Lich::Common::StringProc
- Defined in:
- documented/common/class_exts/stringproc.rb
Overview
Represents a processor for string evaluations.
This class allows for the evaluation of a string as Ruby code.
Instance Method Summary collapse
- #_dump(_d = nil) ⇒ Object
-
#call(*_a) ⇒ Object
Evaluates the stored string as Ruby code.
-
#class ⇒ Class
Returns the class of the object.
-
#initialize(string) ⇒ StringProc
constructor
Initializes a new StringProc instance.
-
#inspect ⇒ String
Returns a string representation of the StringProc instance.
-
#kind_of?(type) ⇒ Boolean
Checks if the object is of a given type.
-
#to_json(*args) ⇒ String
Converts the StringProc instance to JSON format.
Constructor Details
#initialize(string) ⇒ StringProc
Initializes a new StringProc instance.
12 13 14 |
# File 'documented/common/class_exts/stringproc.rb', line 12 def initialize(string) @string = string end |
Instance Method Details
#_dump(_d = nil) ⇒ Object
36 37 38 |
# File 'documented/common/class_exts/stringproc.rb', line 36 def _dump(_d = nil) @string end |
#call(*_a) ⇒ Object
Evaluates the stored string as Ruby code.
32 33 34 |
# File 'documented/common/class_exts/stringproc.rb', line 32 def call(*_a) proc { eval(@string) }.call end |
#class ⇒ Class
Returns the class of the object.
25 26 27 |
# File 'documented/common/class_exts/stringproc.rb', line 25 def class Proc end |
#inspect ⇒ String
Returns a string representation of the StringProc instance.
42 43 44 |
# File 'documented/common/class_exts/stringproc.rb', line 42 def inspect "StringProc.new(#{@string.inspect})" end |
#kind_of?(type) ⇒ Boolean
Checks if the object is of a given type.
19 20 21 |
# File 'documented/common/class_exts/stringproc.rb', line 19 def kind_of?(type) Proc.new {}.kind_of? type end |
#to_json(*args) ⇒ String
Converts the StringProc instance to JSON format.
49 50 51 |
# File 'documented/common/class_exts/stringproc.rb', line 49 def to_json(*args) ";e #{_dump}".to_json(args) end |