Class: BucketMaker::Series
- Inherits:
-
Object
- Object
- BucketMaker::Series
- Defined in:
- lib/bucket_maker/series.rb
Constant Summary collapse
- SERIES_DESCRIPTION =
'description'- SERIES_USER_AFTER =
'created_after'- SERIES_BUCKETS =
'buckets'
Instance Attribute Summary collapse
-
#buckets ⇒ Object
readonly
Returns the value of attribute buckets.
-
#created_after ⇒ Object
readonly
Returns the value of attribute created_after.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #bucket_with_name(bucket_name) ⇒ Object
- #each_bucket ⇒ Object
- #has_bucket?(bucket_name) ⇒ Boolean
- #has_group_in_bucket?(bucket_name, group_name) ⇒ Boolean
-
#initialize(name, options = {}) ⇒ Series
constructor
A new instance of Series.
- #is_bucketable?(bucketable) ⇒ Boolean
Constructor Details
#initialize(name, options = {}) ⇒ Series
Returns a new instance of Series.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bucket_maker/series.rb', line 12 def initialize(name, ={}) @name = name.to_sym @description = [SERIES_DESCRIPTION] || '' @created_after = if [SERIES_USER_AFTER] DateTime.parse([SERIES_USER_AFTER]) else DateTime.parse("1st Jan 1900") end @buckets = [SERIES_BUCKETS].inject({}) do |result, (bucket_name, )| result[bucket_name.to_sym] = BucketMaker::Bucket.new(bucket_name, ) result end if [SERIES_BUCKETS] end |
Instance Attribute Details
#buckets ⇒ Object (readonly)
Returns the value of attribute buckets.
3 4 5 |
# File 'lib/bucket_maker/series.rb', line 3 def buckets @buckets end |
#created_after ⇒ Object (readonly)
Returns the value of attribute created_after.
3 4 5 |
# File 'lib/bucket_maker/series.rb', line 3 def created_after @created_after end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/bucket_maker/series.rb', line 3 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/bucket_maker/series.rb', line 3 def name @name end |
Instance Method Details
#bucket_with_name(bucket_name) ⇒ Object
32 33 34 |
# File 'lib/bucket_maker/series.rb', line 32 def bucket_with_name(bucket_name) @buckets[bucket_name.to_sym] end |
#each_bucket ⇒ Object
26 27 28 29 30 |
# File 'lib/bucket_maker/series.rb', line 26 def each_bucket @buckets.each do |bucket_name, bucket| yield bucket_name, bucket end if block_given? end |
#has_bucket?(bucket_name) ⇒ Boolean
40 41 42 |
# File 'lib/bucket_maker/series.rb', line 40 def has_bucket?(bucket_name) @buckets[bucket_name.to_sym] != nil end |
#has_group_in_bucket?(bucket_name, group_name) ⇒ Boolean
44 45 46 |
# File 'lib/bucket_maker/series.rb', line 44 def has_group_in_bucket?(bucket_name, group_name) has_bucket?(bucket_name) && @buckets[bucket_name.to_sym].has_group?(group_name) end |
#is_bucketable?(bucketable) ⇒ Boolean
36 37 38 |
# File 'lib/bucket_maker/series.rb', line 36 def is_bucketable?(bucketable) bucketable.created_at >= @created_after end |