Class: IB::Account
Instance Method Summary
collapse
#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) && account == other.account
end
|
#advisor? ⇒ Boolean
39
40
41
|
# File 'lib/models/ib/account.rb', line 39
def advisor?
!!(type =~ /Advisor/ || account =~ /\A[D]?[F]{1}/)
end
|
#default_attributes ⇒ Object
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
|
31
32
33
|
# File 'lib/models/ib/account.rb', line 31
def logger Connection.logger
end
|
65
66
67
|
# File 'lib/models/ib/account.rb', line 65
def name self.alias.present? ? self.alias : account
end
|
#print_type ⇒ Object
35
36
37
|
# File 'lib/models/ib/account.rb', line 35
def print_type (test_environment? ? "demo_" : "") + ( user? ? "user" : "advisor" )
end
|
#test_environment? ⇒ Boolean
47
48
49
|
# File 'lib/models/ib/account.rb', line 47
def test_environment?
!!(account =~ /^[D]{1}/)
end
|
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 != account
" alias: "+ self.alias
else
""
end
"<#{print_type} #{account}#{a}>"
end
|
#user? ⇒ Boolean
43
44
45
|
# File 'lib/models/ib/account.rb', line 43
def user?
!!(type =~ /User/ || account =~ /\A[D]?[U]{1}/)
end
|