Sha256: 1ac7c5496d987b415735bc94b8c6a21ed0f4c596d270a09a29b67f1603d59536

Contents?: true

Size: 918 Bytes

Versions: 31

Compression:

Stored size: 918 Bytes

Contents

module Ruboto
  module Util
    module CodeFormatting
      ###########################################################################
      #
      # Methods for formatting code
      #
      def method_call(return_type, method_name, parameters=[], exceptions=nil, body_clause=[])
        ["public #{"#{return_type} " unless return_type.nil? || return_type.empty?}#{method_name}(" + parameters.map{|i| "#{i[1]} #{i[0]}"}.join(", ") + ") #{" throws #{exceptions.join(', ')}" if exceptions && exceptions.any?}{",
        body_clause.indent, "}"]
      end

      def if_else(condition, if_clause, else_clause = [])
        ["if (#{condition}) {", if_clause.indent, else_clause.compact.empty? ? nil : "} else {", else_clause.indent, "}"]
      end

      def try_catch(try_clause, catch_clause)
        ["try {", try_clause.indent, "} catch (RaiseException re) {", catch_clause.indent, "}"]
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
ruboto-0.13.0.rc.0 lib/ruboto/util/code_formatting.rb
ruboto-0.12.0.rc.0 lib/ruboto/util/code_formatting.rb
ruboto-0.11.0 lib/ruboto/util/code_formatting.rb
ruboto-0.11.0.rc.1 lib/ruboto/util/code_formatting.rb
ruboto-0.11.0.rc.0 lib/ruboto/util/code_formatting.rb
ruboto-0.10.2 lib/ruboto/util/code_formatting.rb
ruboto-0.10.2.rc.0 lib/ruboto/util/code_formatting.rb
ruboto-0.10.1 lib/ruboto/util/code_formatting.rb
ruboto-0.10.0 lib/ruboto/util/code_formatting.rb
ruboto-0.10.0.rc.1 lib/ruboto/util/code_formatting.rb
ruboto-0.10.0.rc.0 lib/ruboto/util/code_formatting.rb