Class: Sqreen::Weave::Budget
- Inherits:
-
Object
- Object
- Sqreen::Weave::Budget
- Includes:
- Log::Loggable
- Defined in:
- lib/sqreen/weave/budget.rb
Class Attribute Summary collapse
-
.current ⇒ Object
readonly
Returns the value of attribute current.
Instance Attribute Summary collapse
-
#ratio ⇒ Object
readonly
Returns the value of attribute ratio.
-
#threshold ⇒ Object
readonly
Returns the value of attribute threshold.
Class Method Summary collapse
Instance Method Summary collapse
- #dynamic? ⇒ Boolean
-
#initialize(threshold, ratio = nil) ⇒ Budget
constructor
A new instance of Budget.
- #static? ⇒ Boolean
- #to_h ⇒ Object
Methods included from Log::Loggable
Constructor Details
#initialize(threshold, ratio = nil) ⇒ Budget
Returns a new instance of Budget.
12 13 14 15 |
# File 'lib/sqreen/weave/budget.rb', line 12 def initialize(threshold, ratio = nil) @threshold = threshold @ratio = ratio end |
Class Attribute Details
.current ⇒ Object (readonly)
Returns the value of attribute current.
33 34 35 |
# File 'lib/sqreen/weave/budget.rb', line 33 def current @current end |
Instance Attribute Details
#ratio ⇒ Object (readonly)
Returns the value of attribute ratio.
26 27 28 |
# File 'lib/sqreen/weave/budget.rb', line 26 def ratio @ratio end |
#threshold ⇒ Object (readonly)
Returns the value of attribute threshold.
25 26 27 |
# File 'lib/sqreen/weave/budget.rb', line 25 def threshold @threshold end |
Class Method Details
.update(opts = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sqreen/weave/budget.rb', line 35 def update(opts = nil) Sqreen::Weave.logger.info("budget update:#{opts.inspect}") return @current = nil if opts.nil? || opts.empty? threshold = opts[:threshold] ratio = opts[:ratio] @current = new(threshold, ratio) end |
Instance Method Details
#dynamic? ⇒ Boolean
21 22 23 |
# File 'lib/sqreen/weave/budget.rb', line 21 def dynamic? threshold && ratio end |
#static? ⇒ Boolean
17 18 19 |
# File 'lib/sqreen/weave/budget.rb', line 17 def static? threshold && !ratio end |
#to_h ⇒ Object
28 29 30 |
# File 'lib/sqreen/weave/budget.rb', line 28 def to_h { threshold: threshold, ratio: ratio } end |