Sha256: 9c13eefd5dc95af1350c01b5f54b84288793dd0a29f6624b138ee09ec20b2bf4

Contents?: true

Size: 656 Bytes

Versions: 2

Compression:

Stored size: 656 Bytes

Contents

module Danica
  class Function::Name
    include Common
    attr_reader :name, :containers

    def initialize(name:, variables:)
      @name = name || :f
      @containers = variables.map do |v|
        v = wrap_value(v)
        v = Wrapper::Container.new(v) unless v.container?
        v
      end
    end

    def to(format)
      "#{name}(#{description_variables(format)})"
    end

    def variables
      containers.map(&:content)
    end

    private

    def description_variables(format)
      non_constant_variables.map { |v| v.to(format) }.join(', ')
    end

    def non_constant_variables
      variables.reject(&:constant?)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
danica-2.6.0 lib/danica/function/name.rb
danica-2.5.1 lib/danica/function/name.rb