Sha256: 9ab45b298bee6e9fc8a44d9cd519ae3036e3f87981fdff55af7b3ae57b886506
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
module Albacore::Asmver class Engine 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
albacore-0.6.2.rc1 | lib/albacore/asmver/engine.rb |