Sha256: b024cf81dc654f25c41bfdf753207b85ae7f5f7d60d330047eb26092d57203a8

Contents?: true

Size: 650 Bytes

Versions: 2

Compression:

Stored size: 650 Bytes

Contents

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

    def initialize(name:, variables:)
      @name = name
      @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.5.0 lib/danica/function/name.rb
danica-2.4.4 lib/danica/function/name.rb