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-1.6.1 lib/ruboto/util/code_formatting.rb
ruboto-1.6.0 lib/ruboto/util/code_formatting.rb
ruboto-1.5.0 lib/ruboto/util/code_formatting.rb
ruboto-1.4.1 lib/ruboto/util/code_formatting.rb
ruboto-1.4.0 lib/ruboto/util/code_formatting.rb
ruboto-1.3.1 lib/ruboto/util/code_formatting.rb
ruboto-1.3.0 lib/ruboto/util/code_formatting.rb
ruboto-1.2.0 lib/ruboto/util/code_formatting.rb
ruboto-1.1.2 lib/ruboto/util/code_formatting.rb
ruboto-1.1.1 lib/ruboto/util/code_formatting.rb
ruboto-1.1.0 lib/ruboto/util/code_formatting.rb
ruboto-1.0.3 lib/ruboto/util/code_formatting.rb
ruboto-1.0.2 lib/ruboto/util/code_formatting.rb
ruboto-1.0.1 lib/ruboto/util/code_formatting.rb
ruboto-1.0.0 lib/ruboto/util/code_formatting.rb
ruboto-0.16.0 lib/ruboto/util/code_formatting.rb
ruboto-0.15.0 lib/ruboto/util/code_formatting.rb
ruboto-0.14.0 lib/ruboto/util/code_formatting.rb
ruboto-0.13.0 lib/ruboto/util/code_formatting.rb
ruboto-0.12.0 lib/ruboto/util/code_formatting.rb