lib/fcb.rb in markdown_exec-1.3.8 vs lib/fcb.rb in markdown_exec-1.3.9
- old
+ new
@@ -16,52 +16,24 @@
def initialize(options = {})
@attrs = {
body: nil,
call: nil,
headings: [],
+ dname: nil,
name: nil,
+ oname: nil,
reqs: [],
shell: '',
title: '',
random: Random.new.rand,
text: nil # displayable in menu
}.merge(options)
end
- def to_h
- @attrs
- end
-
- def to_yaml
- @attrs.to_yaml
- end
-
- private
-
- # 2023-10-07 proposed but not functional with code
- #
- # def method_missing(method, *args, &block)
- # method_name = method.to_s
-
- # if method_name[-1] == '='
- # @attrs[method_name.chop.to_sym] = args[0]
- # elsif @attrs.key?(method_name.to_sym)
- # @attrs[method_name.to_sym]
- # else
- # super
- # end
- # rescue StandardError => err
- # warn(error = "ERROR ** FCB.method_missing(method: #{method_name}, *args: #{args.inspect}, &block)")
- # warn err.inspect
- # warn(caller[0..4])
- # raise err # Here, we simply propagate the original error instead of wrapping it in a StandardError.
- # end
-
# :reek:ManualDispatch
def method_missing(method, *args, &block)
method_name = method.to_s
-
if @attrs.respond_to?(method_name)
@attrs.send(method_name, *args, &block)
elsif method_name[-1] == '='
@attrs[method_name.chop.to_sym] = args[0]
else
@@ -77,10 +49,18 @@
end
def respond_to_missing?(method_name, _include_private = false)
@attrs.key?(method_name.to_sym) || super
end
+
+ def to_h
+ @attrs
+ end
+
+ def to_yaml
+ @attrs.to_yaml
+ end
end
end
if $PROGRAM_NAME == __FILE__
require 'minitest/autorun'
@@ -90,10 +70,12 @@
def setup
@fcb_data = {
body: 'Sample body',
call: 'Sample call',
headings: %w[Header1 Header2],
+ dname: 'Sample name',
name: 'Sample name',
+ oname: 'Sample name',
reqs: %w[req1 req2],
shell: 'bash',
text: 'Sample Text',
title: 'Sample Title'
}