Sha256: 392a4b9435014b463174acb4bb84a0529d7530967cf0d4436a1f587feb584dc0

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

class AssemblyInfoEngine
  def build_attribute(attr_name, attr_data)
    attribute = "#{@start_token}assembly: #{attr_name}("
    
    if attr_data != nil
      if attr_data.is_a? Hash
        # Only named parameters
        attribute << build_named_parameters(attr_data)
      elsif attr_data.is_a? Array
        if attr_data.last.is_a? Hash
          # Positional and named parameters
          attribute << build_positional_parameters(attr_data.slice(0, attr_data.length - 1))
          attribute << ", "
          attribute << build_named_parameters(attr_data.last)
        else
          # Only positional parameters
          attribute << build_positional_parameters(attr_data)
        end
      else
        # Single positional parameter
        attribute << "#{attr_data.inspect}"
      end
    end
    
    attribute << ")#{@end_token}"
  end
  
  def build_named_parameters(data)
    params = []
    data.each_pair { |k, v| params << "#{k.to_s} #{@assignment} #{v.inspect}" }
    params.join(", ")
  end
  
  def build_positional_parameters(data)
    data.flatten.map{ |a| a.inspect }.join(", ")
  end

  def build_using_statement(namespace)
    "#{@using} #{namespace}#{@statement_terminator}"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
albacore-0.3.6 lib/albacore/assemblyinfolanguages/assemblyinfoengine.rb
albacore-1.0.0.rc.2 lib/albacore/assemblyinfolanguages/assemblyinfoengine.rb
albacore-1.0.0.rc.1 lib/albacore/assemblyinfolanguages/assemblyinfoengine.rb
albacore-0.3.5 lib/albacore/assemblyinfolanguages/assemblyinfoengine.rb
albacore-0.3.4 lib/albacore/assemblyinfolanguages/assemblyinfoengine.rb