Class: AlphaCard::Account

Inherits:
AlphaCardObject show all
Defined in:
lib/alpha_card/objects/account.rb

Overview

Implementation of Alpha Card Services account object. Contains credentials (username and password) for the Alpha Card Gateway API access.

Instance Method Summary collapse

Methods inherited from AlphaCardObject

#filled_attributes

Constructor Details

#initialize(username, password) ⇒ Account

AlphaCard::Account constructor.

Examples:

AlphaCard::Account.new('demo', 'password')

#=> #<AlphaCard::Account:0x000000039b18a8 @username="demo", @password="password">

Parameters:

  • username (String)
  • password (String)


20
21
22
23
# File 'lib/alpha_card/objects/account.rb', line 20

def initialize(username, password)
  self.username = username
  self.password = password
end

Instance Method Details

#filled?Boolean

Say if all the credentials of Account is filled. Username and password can’t be a nil object or an empty String.

Examples:

 = AlphaCard::Account.new('demo', 'password')
.filled?

#=> true

 = AlphaCard::Account.new('', nil)
.filled?

#=> false

Returns:

  • (Boolean)

    True if username and password is filled.



43
44
45
46
# File 'lib/alpha_card/objects/account.rb', line 43

def filled?
  attrs = [username, password]
  !attrs.empty? && attrs.all? { |attr| attr && !attr.strip.empty? }
end