lib/danica/operator/chained.rb in danica-2.4.2 vs lib/danica/operator/chained.rb in danica-2.4.3

- old
+ new

@@ -14,33 +14,33 @@ def include?(value) value = wrap_value(value) variables.include?(value) end - def to_tex - to_string(:tex) + def to(format) + extractor = string_extractor(format) + variables.procedural_join(extractor, &join_proc(symbol(format))) end - def to_gnu - to_string(:gnu) - end - private - def to_string(type) - extractor = string_extractor("to_#{type}") - symbol = { tex: tex_symbol, gnu: gnu_symbol }[type] - variables.procedural_join(extractor, &join_proc(symbol)) + def symbol(format) + case format.to_sym + when :tex + tex_symbol + when :gnu + gnu_symbol + end end def join_proc(symbol) proc { " #{symbol} " } end def string_extractor(method) proc do |parcel| parcel = wrap_as_group(parcel) - parcel.public_send(method) + parcel.to(method) end end def repack(other) other_variables = other.is_a?(self.class) ? other.variables : [ other ]