Sha256: bf87cabd2f26b06dcafd3df25275ae8103e0845fc86f837ff138af7ac7b6a0d9
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module Danica class Operator class Chained < Operator def variables=(vars) @variables = vars.map { |v| wrap_value(v) } end def to_f chain(variables.map(&:to_f)) end def include?(value) value = wrap_value(value) variables.include?(value.content) end def to(format, **options) extractor = string_extractor(format, **options) variables.procedural_join(extractor, &join_proc(symbol(format))) end def variables @variables.map(&:content) end private 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(*args) proc do |parcel| parcel = wrap_as_group(parcel) parcel.to(*args) end end def chain(numbers) numbers.inject do |a, b| chain_operation(a, b) end.to_f end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
danica-2.7.7 | lib/danica/operator/chained.rb |
danica-2.7.6 | lib/danica/operator/chained.rb |
danica-2.7.5 | lib/danica/operator/chained.rb |