module SolanaRpcRuby::HelperMethods

Namespace for helper methods.

Public Instance Methods

blank?(object) click to toggle source

Checks if the object is nil or empty.

@param object [String, Array, Hash]

@return [Boolean]

# File lib/solana_rpc_ruby/helper_methods.rb, line 9
def blank?(object)
  raise ArgumentError, 'Object must be a String, Array or Hash or nil class.'\
    unless object.is_a?(String) || object.is_a?(Array) || object.is_a?(Hash) || object.nil?
  
  object.nil? || object.empty?
end
create_method_name(method) click to toggle source

Creates method name to match names required by Solana RPC JSON.

@param method [String]

@return [String]

# File lib/solana_rpc_ruby/helper_methods.rb, line 21
def create_method_name(method)
  return '' unless method && (method.is_a?(String) || method.is_a?(Symbol))

  method.to_s.split('_').map.with_index do |string, i|
    i == 0 ? string : string.capitalize
  end.join
end