Class: PostfixAdmin::Mailbox
Constant Summary
ApplicationRecord::RE_DOMAIN_NAME_LIKE, ApplicationRecord::RE_DOMAIN_NAME_LIKE_BASE, ApplicationRecord::RE_DOMAIN_NAME_LIKE_WITH_ANCHORS, ApplicationRecord::RE_EMAIL_LIKE, ApplicationRecord::RE_EMAIL_LIKE_BASE, ApplicationRecord::RE_EMAIL_LIKE_WITH_ANCHORS
Instance Method Summary
collapse
#scheme_prefix
#active_str, #has_timestamp_columns?, #inactive?, #set_current_time_to_timestamp_columns
Instance Method Details
#quota_display_str(format: "%6.1f") ⇒ Object
122
123
124
|
# File 'lib/postfix_admin/models/mailbox.rb', line 122
def quota_display_str(format: "%6.1f")
"%s / %s" % [quota_usage_str(format: format), quota_mb_str(format: format)]
end
|
#quota_mb ⇒ Object
87
88
89
90
91
|
# File 'lib/postfix_admin/models/mailbox.rb', line 87
def quota_mb
raise Error, "quota is out of range: #{quota}" if quota < 0
quota / KB_TO_MB
end
|
#quota_mb=(value) ⇒ Object
93
94
95
96
97
|
# File 'lib/postfix_admin/models/mailbox.rb', line 93
def quota_mb=(value)
raise Error, "quota is out of range: #{value}" if value < 0
self.quota = value * KB_TO_MB
end
|
#quota_mb_str(format: "%6.1f") ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/postfix_admin/models/mailbox.rb', line 109
def quota_mb_str(format: "%6.1f")
case quota
when -1
"Disabled"
when 0
"Unlimited"
else
quota_mb = quota / KB_TO_MB.to_f
format % quota_mb
end
end
|
#quota_usage_str(format: "%6.1f") ⇒ Object
99
100
101
102
103
104
105
106
107
|
# File 'lib/postfix_admin/models/mailbox.rb', line 99
def quota_usage_str(format: "%6.1f")
usage_mb = if quota_usage
usage_mb = quota_usage.bytes / KB_TO_MB.to_f
else
0.0
end
format % usage_mb
end
|