Class: Bidu::House::Report::Range

Inherits:
ActiveRecord show all
Defined in:
lib/bidu/house/report/range.rb

Constant Summary collapse

ALLOWED_PARAMETERS =
[:period, :maximum, :minimum]
DEFAULT_OPTION =
{
  period: 1.day,
  scope: :all,
  minimum: nil,
  maximum: nil
}

Instance Attribute Summary

Attributes inherited from Bidu::House::Report

#json

Instance Method Summary collapse

Methods inherited from Bidu::House::Report

#status

Constructor Details

#initialize(options) ⇒ Range

Returns a new instance of Range.



16
17
18
# File 'lib/bidu/house/report/range.rb', line 16

def initialize(options)
  super(DEFAULT_OPTION.merge(options))
end

Instance Method Details

#as_jsonObject



28
29
30
31
32
33
# File 'lib/bidu/house/report/range.rb', line 28

def as_json
  {
    status: status,
    count: count
  }
end

#countObject



35
36
37
# File 'lib/bidu/house/report/range.rb', line 35

def count
  scoped.count
end

#error?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/bidu/house/report/range.rb', line 24

def error?
  @error ||= !count_in_range?
end

#scopedObject



20
21
22
# File 'lib/bidu/house/report/range.rb', line 20

def scoped
  @scoped ||= fetch_scoped(last_entries, scope)
end