Class: Marameters::Sourcers::Function
- Inherits:
-
Object
- Object
- Marameters::Sourcers::Function
- Defined in:
- lib/marameters/sourcers/function.rb
Overview
Obtains the literal source of a function’s body.
Constant Summary collapse
- PATTERN =
/ (?:(?<function>proc|->))? # Statement. \s* # Optional space. \{ # Block open. (?<body>.*?) # Source code body. \} # Block close. /x
Instance Method Summary collapse
- #call(function) ⇒ Object
-
#initialize(pattern: PATTERN, reader: Readers::Any.new) ⇒ Function
constructor
A new instance of Function.
Constructor Details
Instance Method Details
#call(function) ⇒ Object
21 |
# File 'lib/marameters/sourcers/function.rb', line 21 def call(function) = reader.call(function).then { |line| line.match(pattern)[:body].strip } |