Class: IB::Account

Inherits:
Model show all
Includes:
BaseProperties
Defined in:
lib/models/ib/account.rb

Instance Method Summary collapse

Methods included from BaseProperties

#as_table, #content_attributes, #invariant_attributes, #set_attribute_defaults, #table_header, #table_row, #update_missing

Instance Method Details

#==(other) ⇒ Object



51
52
53
54
# File 'lib/models/ib/account.rb', line 51

def == other
	super(other) ||
		other.is_a?(self.class) &&  == other.
end

#advisor?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/models/ib/account.rb', line 39

def advisor?
	!!(type =~ /Advisor/ ||  =~ /\A[D]?[F]{1}/)
end

#default_attributesObject



24
25
26
27
28
29
# File 'lib/models/ib/account.rb', line 24

def default_attributes
	super.merge account: 'X000000'
	super.merge alias: ''
	super.merge type: 'Account'
	super.merge connected: false
end

#loggerObject

nodoc#



31
32
33
# File 'lib/models/ib/account.rb', line 31

def logger  #nodoc#
	Connection.logger
end

#nameObject

nodoc#



65
66
67
# File 'lib/models/ib/account.rb', line 65

def name  #nodoc#
	self.alias.present? ? self.alias : 
end

nodoc#



35
36
37
# File 'lib/models/ib/account.rb', line 35

def print_type #nodoc#
	(test_environment? ? "demo_"  : "") + ( user? ? "user" : "advisor" )
end

#test_environment?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/models/ib/account.rb', line 47

def test_environment?
	!!( =~ /^[D]{1}/)
end

#to_humanObject



56
57
58
59
60
61
62
63
# File 'lib/models/ib/account.rb', line 56

def to_human
	a = if self.alias.present?  && self.alias != 
				" alias: "+ self.alias
			else
				""
			end
		"<#{print_type} #{}#{a}>"
end

#user?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/models/ib/account.rb', line 43

def user?
	!!(type =~ /User/ ||  =~ /\A[D]?[U]{1}/)
end